Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • State Management

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 34
    Comment on it

    Types of state management


    There are two types of state management techniques:
    A. client side
    B. server side.

    Client side state management are as below:

    1. Hidden Field
    2. View State
    3. Cookies
    4. Control State
    5. Query Strings


    Server side state management are as below

    1. Session
    2. Application

    Lets see all some of the state with example:


    Hidden Field

    <asp:HiddenField ID="HiddenField1" runat="server"  />  
    
     if (HiddenField1.Value != null)
       {
        int val= Convert.ToInt32(HiddenField1.Value) + 1;
        HiddenField1.Value = val.ToString();
        Label1.Text = val.ToString();
       }
    


    ViewState

    protected void PageLoad(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            if (ViewState["count"] != null)
            {
                int ViewstateVal = Convert.ToInt32(ViewState["count"]) + 1;
                Label1.Text = ViewstateVal.ToString();
                ViewState["count"]=ViewstateVal.ToString();
            }
            else
            {
                ViewState["count"] = "1";
            }
        }
    }
    protected void Button1Click(object sender, EventArgs e)
    {
           Label1.Text=ViewState["count"].ToString();
    }
    


    Session

     Session["Count"] = 0;
    


    Application

    Application["Count"] = Convert.ToInt32(Application["Count"]) + 1; //Set Value to The Application Object
    
    Label1.Text = Application["Count"].ToString(); //Get Value from the Application Object 
    
    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: