ASP.NET 4 Unleased - p 45

Using the SqlDataSource Control Text=’’ TextMode=”MultiLine” Columns=”60” Rows=”4” Runat=”server” / ” Runat=”server” The ControlID property is set to the value __page. This value is the automatically generated ID for the Page class. The PropertyName | 414 CHAPTER 9 Using the SqlDataSource Control Text Bind Comments TextMode MultiLine Columns 60 Rows 4 Runat server br br asp Button id btnSubmit Text Submit CommandName Insert Runat server InsertItemTemplate asp FormView hr asp GridView id grdGuestBook DataSourceID srcGuestBook Runat server asp SqlDataSource id srcGuestBook SelectCommand SELECT FROM GuestBook ORDER BY Id DESC InsertCommand INSERT GuestBook IPAddress Name Comments VALUES @IPAddress @Name ConnectionString ConnectionStrings GuestBook Runat server InsertParameters asp ControlParameter Name IPAddress ControlID page PropertyName IPAddress InsertParameters asp SqlDataSource div form body html The ControlID property is set to the value_page. This value is the automatically gener- ated ID for the Page class. The PropertyName property has the value IPAddress. This property is defined in the page. From the Library of Wow eBook Using Parameters with the SqlDataSource Control 415 Using the CookieParameter Object The CookieParameter object represents a browser-side cookie. The CookieParameter includes all the properties of the base Parameter class and the following additional property CookieName The name of the browser cookie. The page in Listing illustrates how you can use the CookieParameter object. The page contains a voting form that you can use to vote for your favorite color. A cookie is added to the user s browser to identify the user and prevent someone from cheating by voting more than once see Figure . FIGURE Vote on your favorite color. LISTING 9 @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD script runat server void Page_Load if VoterId null string identifier .ToString From the Library of Wow eBook 416 CHAPTER 9 Using the SqlDataSource Control HttpCookie voteCookie new HttpCookie VoterId identifier voteCookie

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.