Saturday 1 August 2015

Client-Side State Management

Client-Side State Management

·         doesn't use server resources
·         typically have minimal security but fast server performance
·         stores information either in the page or on the client computer

View State

  •  stored in hidden field using _VIEWSTATE keyword
  •  By default, ViewState is serialized into a base-64 encoded string
  • It is only for that specific .aspx page. Cannot be used in-between 2 different pages.
  • We can use  EnableViewState property of the connrols to enabled or disabled the ViewState
  • We can also some other variable info in .cs file like:
// Write an item to view state
ViewState["MyBalance"] = myBalance;
// Read the item back following a postback
decimal myBalance = (decimal) ViewState["MyBalance"];

  Control State

  • Similar to View State
  • Usually used for custom control 
  • Unlike view-state it cannot be turned off.

  Cookies

  • Small bit of text stored on the client file system or in-memory in the client browser session
  • Are associated with a website, not a specific page.So, browser will exchange information no matter what page you requested from the website.
  • Each cookie can be up to a maximum of 4 KB in length. 20 cookies/site
  • Cannot use if cookies disabled by user

  •    Temporary cookiesalso known as session cookies, exist in the memory space of a browser. When the browser is closed, all session cookies added to the browser are lost

  • persistent cookie is saved as a text file in the file system of the client computer.
          HttpCookie cookie = new HttpCookie ("UserName", "Prabhat");
          Response.Cookies.Add (cookie);


           QueryString

          • It is the information which is added at the end of page url.
          • Help in passing information from one page to another.
          • example:
          pkpaspdotnet.blogspot.in ? id=1&author=prabhat
          • the query string starts with a question mark (?) and includes two attribute/value pairs, one called "id"category" and the other called "author"

          No comments:

          Post a Comment