0

I want to declare a integer variable in global scope but do not want to that its value become 0 every time the page is post-back

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Error : System.Web.UI.Page
{//should i declare here????
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
5
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by rohand
0

>I want to declare a integer variable in global scope

You can store value with global scope.

protected void Page_Load(object sender, EventArgs e)
    {
        Application.Lock();
        if(Application["key1"]==null) {
             Application["key1"]=10;
        }
        
        int n=(int)Application["key1"];
       Application.Unlock();
     }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.