![]() Load the content from the display source.When the user selects a color from the drop-down list on the main page (Figure 2), ASP.NET will save the user preference inside a cookie with an expiration time of 31 days with the following code in : protected void ddlColors_SelectedIndexChanged(object sender, EventArgs e)Īs soon as the user adds the Web Slice to Internet Explorer 8, ASP.NET will: The ProfileProvider class simplifies the interaction with the CookieHelper class by providing two methods: GetColor and SaveColor. The CookieHelper class (Figure 1) encapsulates these actions to allow you to more easily read, write, and delete cookies. Likewise, to delete a cookie, subtract a year from its expiration date. In order to make a cookie persistent across different browser sessions, you need to specify the cookie's expiration, such as: public static void WriteCookie(HttpCookie cookie)Ĭookie.Expires = (31) CookieHelper.cs simplifies the process of storing and retrieving values from a cookie.ProfileProvider.cs defines a custom class that reads and writes the color value to the user's profile (in this case, a cookie).DisplayWebSlice.ascx renders the Web Slice content by reading the cookie and setting the background color.DisplayPage.aspx is the alternative display source for the Web Slice. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |