Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
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 ASf.NET Parameters with the SqlDataSource Control 415 Using the ASP.NET 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 9.19 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 9.12 . FIGURE 9.12 Vote on your favorite color. LISTING 9.19 Vote.aspx 9 @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML 1.1 EN http www.w3.org TR xhtml11 DTD xhtml11.dtd script runat server void Page_Load if Request.Cookies VoterId null string identifier Guid.NewGuid .ToString From the Library of Wow eBook 416 CHAPTER 9 Using the SqlDataSource Control HttpCookie voteCookie new HttpCookie VoterId identifier voteCookie.Expires DateTime.MaxValue Response.AppendCookie voteCookie