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
S
Client side
| |
Viewstate
|
Application State
|
Controlstate
|
SessionState
|
HiddenFields
|
Profileproperties
|
Cookies
| |
Querystrings
| |
VIEWSTATE
- All the values of controls are stored in hiddenfields in the last postback.
- The viewstate is page level and control.i.e controls have enable viewstate properity.
- We can put enable viewstate false for the whole page.if we use in page directive it will work.Then it works very fast..
- Viewstate is page level.
CONTROLSTATE
- It can be used to store private critical condition.
HIDDENFIELDS
- Hidden fields are used to store data at page level.These fields are not rendered by the browser.
Adv
- Simple to implement.
- Can store small amount of data so, they take less size.
Disadvantages
- Inappropriate for sensitive data
- 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
- Cookie is a piece of text that is stored in system or browser.
- It contains site specific information that the server sends to client along with pageoutput
- 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
- They are used to pass information from one page to another
- Information is appended to end of the page.
www.gmail.com/.inbox.aspx?id=1&name="suhas";
- Querystring is hackable.
SESSION STATE
- A session is used to store the values that can be used throughout the application.
- 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
- It is a global storage mechanism that is accessible from all pages in web application.
- It is useful for storing information that needs to be maintained between server round trips and between requests for pages.
PROFILE PROPERTIES
- It allows you store user specific data.
- Associates information with an individual user.
No comments:
Post a Comment