9. Client-side State Management Query Strings What are Query Strings? Query strings are data that is appended to the end of a page URL. They are commonly used to hold String data like page numbers or search terms or other data that isn't confidential. The user can see the values which the query string holds without using special operations. An example of a query string can look like http://www.Student.co.il?a=1;b=2. The Query String Structure As written earlier, query strings are appended to the end of a URL. First a question mark is appended to the URL's end and then every parameter that we want to hold in the query string . The parameters declare the parameter name followed by = symbol which followed by the data to hold. Every parameter is separated with the ampersand symbol(&).
10.
11. Client-side State Management Hidden Field What are Hidden Fields ? A hidden field does not render visibly in the browser, but you can set its properties just as you can with a standard control. When a page is submitted to the server, the content of a hidden field is sent in the HTTP Form collection along with the values of other controls. A hidden field acts as a repository for any page-specific information that you would like to store directly in the page. Hidden field stores a single variable in its value property and must be explicitly added it to the page.ASP.NET provides the HtmlInputHidden control that offers hidden field functionality. Hidden Fields Values Hidden fields store only one value in their value property. The value is saved as a string and therefore in order to use it for other types you need to perform casting. You can see the stored data easily by using the View Source operation of the browser. You can see it by clicking the right mouse button and then choosing View Source from the menu (if the operation is available). The values has page context and therefore when you leave a page the data stored in the hidden fields is disposed.
12.
13. Cookies Client-side State Management What are Cookies? A cookie is a piece of data that is saved either in the memory of the client’s web browser or as a text file in the file system of the client. Cookies are used to identify a user, to store state information, preferences of the user and etc. How Does Cookies Mechanism Work? The mechanism of cookies is simple. When a client request a web page from a server the first request isn't containing a cookie . The server identify that the client has no cookie and generate . Then the server sends the cookie to the client and from now on the client will send the cookie in every request and the server will send the cookie in every response.
14.
15.
16.
17. View State Client-side State Management What is View State? ViewSate is a technique to preserve controls data and maintain their properties during multiple requests for the same page how, the ViewState property provides a dictionary object for retaining values between multiple requests for the same page. When an ASP.NET page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden filed. How to use View State? You can use the ViewState property of the Control or Page class to add values to View State. The ViewState property exposes a dictionary of key and value pairs. For example, the following statement adds the string Hello World! to View State: ViewState(“message”) = “Hello World!”