Application State


  1. Application State variables are available across all pages and across all sessions. Application State variables are like multi-user global data.
  2. Application State variables are stored on the web server.
  3. Application State variables are cleared, when the process hosting the application is restarted.
Example:-

Application_state.aspx :-



<div align="center">
            <table ">
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" ></asp:Label></td>
               </tr>
            <tr>
                <td>
                    <asp:Button ID="Button1" runat="server" Text="click" OnClick="Button1_Click" /></td>
            </tr>
        </table>

Application_state.aspx.cs :-


 int count = 0;
    protected void Button1_Click(object sender, EventArgs e)
    {
        if(Application["count"]!=null)
        {
            count = (int)Application["count"];
        } count++;
        Label1.Text="you have click me "+count+"times<br/>";
        Application["count"] = count;
    }

No comments:

Post a Comment

Xamarin Android Project App

Xamarin Android Project App 1. Xamarin -- Make a CALCULATOR Android App   https://drive.google.com/open?id=0B8OPCXLrtKPmWC1FWWtFM2lraVk...