This is probably a little weird question.
In this example everytime button is clicked,counter is incremented
<%@ Page Language="C#" %>
<html>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
lblCounter.Text = Counter.ToString();
Counter++;
}
public int Counter
{
get
{ //is an element with "intX" key
from page's StateBack object?
if (ViewState["intX"] != null )
{
return ((int)ViewState["intX"]);
}
return 0;
}
set
{
ViewState["intX"] = value;
}
}
</script>
<body>
<form runat="server" ID="Form
<asp:Label id="lblCounter" runat="server" />
<asp:Button id="btn" text="Increment Counter" runat="server" />
</form>
</body>
</html>
Can someone tell me,why in this example there isn't any StateBag object defined?
Is it because ASP.NET automaticly creates one for your page?
DOES an element with intX key exist in page's StateBag object?
And last,have controls(for instance some Label control) their own StateBag objects created or do they all store their view state in the same StateBag instance?
Thank you for your help
In this example everytime button is clicked,counter is incremented
<%@ Page Language="C#" %>
<html>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
lblCounter.Text = Counter.ToString();
Counter++;
}
public int Counter
{
get
{ //is an element with "intX" key
from page's StateBack object?
if (ViewState["intX"] != null )
{
return ((int)ViewState["intX"]);
}
return 0;
}
set
{
ViewState["intX"] = value;
}
}
</script>
<body>
<form runat="server" ID="Form
<asp:Label id="lblCounter" runat="server" />
<asp:Button id="btn" text="Increment Counter" runat="server" />
</form>
</body>
</html>
Can someone tell me,why in this example there isn't any StateBag object defined?
Is it because ASP.NET automaticly creates one for your page?
DOES an element with intX key exist in page's StateBag object?
And last,have controls(for instance some Label control) their own StateBag objects created or do they all store their view state in the same StateBag instance?
Thank you for your help