B
BobRoyAce
I have a C# ASP.NET page that I inherited which has two panels on it. It
only ever shows one or the other. Initially, it shows panel one. Then, if
the user clicks on a certain button, it ultimately shows the other (after a
postback, of course). What I need to do it put code into place that will
allow code in the Page_Load event, in the case of a PAGE REFRESH (NOTE: Page
involved is stored in a FRAME which is part of a FRAMESET), to know which
panel to show. What is the best way to accomplish something like this?
Should I use Request.Cookies["Panel"] or ViewState["Panel"]?
I tried the latter, but after clicking on a button, resulting in showing
Panel2, and then refreshing the page, ViewState["Panel"] was null. I didn't
explicitly set it to null. What events result in ViewState items being set
to null?
A problem I was having with the Request.Cookies way of doing things was that
I was trying to check to see, in the Page_Load event, where IsPostBack was
false, if the Request.Cookies["Panel"] cookie was already set (i.e. not
null) and the code was failing telling me "Object reference not set to an
instance of an object." The line of code that produced this error was as
follows:
if (Request.Cookies["Panel"] != null)
Any insights would be appreciated.
only ever shows one or the other. Initially, it shows panel one. Then, if
the user clicks on a certain button, it ultimately shows the other (after a
postback, of course). What I need to do it put code into place that will
allow code in the Page_Load event, in the case of a PAGE REFRESH (NOTE: Page
involved is stored in a FRAME which is part of a FRAMESET), to know which
panel to show. What is the best way to accomplish something like this?
Should I use Request.Cookies["Panel"] or ViewState["Panel"]?
I tried the latter, but after clicking on a button, resulting in showing
Panel2, and then refreshing the page, ViewState["Panel"] was null. I didn't
explicitly set it to null. What events result in ViewState items being set
to null?
A problem I was having with the Request.Cookies way of doing things was that
I was trying to check to see, in the Page_Load event, where IsPostBack was
false, if the Request.Cookies["Panel"] cookie was already set (i.e. not
null) and the code was failing telling me "Object reference not set to an
instance of an object." The line of code that produced this error was as
follows:
if (Request.Cookies["Panel"] != null)
Any insights would be appreciated.