In chapter 8 in the try it out exercise on implementing View state Properties we create a banner in the AboutUs.aspx page on top of the banner that is in the master page.
During the execution of the first AboutUs.aspx call where the NavigateUrl is set to p2p.wrox.com as below:
Code:
public string NavigateUrl
{
get
{
object _navigateUrl = ViewState["NavigateUrl"];
if (_navigateUrl != null)
{
return (string)_navigateUrl;
}
return "http://p2p.wrox.com";
}
set
{
ViewState["NavigateUrl"] = value;
}
}
This
portion makes sense.
However, during the
Code:
protected void Page_Load(object sender, EventArgs e)
{
switch (DisplayDirection)
{
case Direction.Horizontal:
HorizontalPanel.Visible = true;
VerticalPanel.Visible = false;
HorizontalLink.HRef = NavigateUrl;
break;
case Direction.Vertical:
HorizontalPanel.Visible = false;
VerticalPanel.Visible = true;
VerticalLink.HRef = NavigateUrl;
break;
}
}
The switch statement is executed twice (I think 1 for each banner control) and the correct viewstate property is retrieved. The master page banner has a link to
www.wrox.com and the additional banner in aboutUs to p2p.wrox.com.
Does this mean that view state property is maintained for each control? If so, then I am curious to know what is the scope of the view state prop, meaning does each and every control have a viewstate property and what does not have?
Thanks in advance.
To Imaar... This book rocks. for a beginner like me, I love it.