Friday, 12 July 2013

State Management


   State Management is a process by which you maintain state and page information over multiple requests for the same or different pages.We can store the values and use it where ever we need.
S


Client side
Serverside
Viewstate
Application State
Controlstate
SessionState
HiddenFields
Profileproperties
Cookies

Querystrings






VIEWSTATE 


  1. All the values of controls are stored in hiddenfields in the last postback.
  2. The viewstate is page level and control.i.e controls have enable viewstate properity.
  3. We can put enable viewstate false for the whole page.if we use in page directive it will work.Then it works very fast..
  4. Viewstate is page level.

CONTROLSTATE

  1. It can be used to store private critical condition.

HIDDENFIELDS

  1. Hidden fields are used to store data at page level.These fields are not rendered by the browser.
Adv
  1. Simple to implement.
  2. Can store small amount of data so, they take less size.
Disadvantages 
  1. Inappropriate for sensitive data
  2. Hidden field values can be intercepted(Clearly visible when passed over a network).
Syntax:-

Hiddenfield1.value="Create hidden field";  //Assign value
string str=hiddenfield1.value;  //retriving value.


COOKIES

  1. Cookie is a piece of text that is stored in system or browser.
  2. It contains site specific information that the server sends to client along with pageoutput
  3. Cookies can be temperory and can be disabled.
syntax

Response.cookie["CookieName"].value="10";//Assigning

Response.cookie["CookieName"].Expires=Datetime.now.addDays(1);//Expires after 1 day from now


QUERYSTRINGS  

  1. They are used to pass information from one page to another
  2. Information is appended to end of the page.
Syntax   
www.gmail.com/.inbox.aspx?id=1&name="suhas";

  1. Querystring is hackable.

SESSION STATE

  1. A session is used to store the values that can be used throughout the application.
  2. It is application level.
syntax

Session["UserName"]=txtName.text;// Assign values in textbox to session.

lblName.text=convert.tostring(Session["UserName"]);//The value is displayed as Label.

APPLICATION STATE

  1. It is a global storage mechanism that is accessible from all pages in web application.
  2. It is useful for storing information that needs to be maintained between server round trips and between requests for pages.

PROFILE PROPERTIES

  1. It allows you store user specific data.
  2. Associates information with an individual user.

No comments:

Post a Comment