serving the solutions day and night

Pages

Showing posts with label state management. Show all posts
Showing posts with label state management. Show all posts

Saturday, April 3, 2010

ASP.NET State Management - Viewstate VS Session Variables


ASP.NET State Management - Viewstate VS Session Variables

ViewState

vscount.aspx
private int count;
protected void Page_Load(object sender, EventArgs e)
{
    count = Convert.ToInt32(ViewState["count"]);
}

protected void btnCount_Click(object sender, EventArgs e)
{
    count++;
    ViewState["count"] = count;
    lblView.Text = ViewState["count"].ToString();
}

protected void btnView_Click(object sender, EventArgs e)
{
    Response.Redirect("sesview.aspx");
}


ASP.NET State Management

ASP.NET State Management
A Web application is stateless. For example, by default if a user enters information into a text box on an HTML Web page, that information is sent to the server. However, it is not returned to the browser in the response. ASP.NET help you preserve data on both a per-page basis and an application-wide basis. These features are as follows:

  1. View state
  2. Control state
  3. Hidden fields
  4. Cookies
  5. Query strings
  6. Application state
  7. Session state
  8. Profile Properties

View state, control state, hidden fields, cookies, and query strings all involve storing data on the client in various ways.

Application state, session state, and profile properties all store data in memory on the server.