Can someone please tell me when the ViewState is loaded? My
understanding, based on
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conControlExecutionLifecycle.asp
is that it should be loaded before the Page_Load event, however, given
the following code I don't get the expected results.
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack & ViewState["CurrentTab"] != null)
{
_currentTab = (PageTabs)ViewState["CurrentTab"];
}
paintTabStrips();
}
The ViewState is set during the first call to the page. And just to be
sure of it, when I step through this code on the first iteration
(Page.IsPostBack=false) the value is in the ViewState, however on
PostBacks it is not there!!! AAARRRRGGGHHH!!!!!
Am I missing something fundamental or is it just my mind that has gone
lost?
Thanks
dnz - 16 Feb 2006 08:22 GMT
Hi Frank,
what is the type of PageTabs?
Frank skrev:
> Can someone please tell me when the ViewState is loaded? My
> understanding, based on
[quoted text clipped - 20 lines]
>
> Thanks
Frank - 16 Feb 2006 08:33 GMT
I'm wouldn't have though it would matter but:
[Flags]
public enum PageTabs
{
SummaryList = 0x1,
DebtorInfo = 0x2,
AdditionalInfo = 0x4,
SkipDetails = 0x8,
AccountInfo = 0x10,
AddressHistory = 0x20,
Invoices = 0x40,
AddressInfo = 0x80,
Search = 0x100,
Results = 0x200,
CreditReport = 0x400,
QMail = 0x800,
Diary = 0x1000
}
Jason Myers - 16 Feb 2006 10:30 GMT
Have u ensured that the viewstate property on the control is set to True?
> Can someone please tell me when the ViewState is loaded? My
> understanding, based on
[quoted text clipped - 20 lines]
>
> Thanks
Frank - 16 Feb 2006 12:45 GMT
This is not for a control per se...it's just the ViewState bag for the
page, and yes, it is enabled for the page.
Thanks,
Frank
> Have u ensured that the viewstate property on the control is set to True?
>
[quoted text clipped - 22 lines]
> >
> > Thanks
dnz - 17 Feb 2006 10:00 GMT
Hi Frank,
I cannot reproduce your problem. When I do as you described, it works
as it should.
Try Nikhil Khotari's Web Development Helper (
http://www.nikhilk.net/Project.WebDevHelper.aspx ) and inspect the
serialized viewstate in the hidden field in the html.
Frank - 20 Feb 2006 12:26 GMT
Here is a break-down of methods that are called on the page. What I
find strange is that the ViewState property bag is not null when I
check in Page_Load, just the value I need.
Page.IsPostBack == false:
OnInit
InitializeComponent
(custom - ignore) InitializeSession
(custom - ignore) paintPanel
(custom - ignore) buildPanelDebtorInfo
(custom - ignore) bindPhoneNumberGrid
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore) _uiPhoneNumberGrid_ItemDataBound
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore) _uiPhoneNumberGrid_ItemDataBound
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore) _uiPhoneNumberGrid_ItemDataBound
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore) _uiPhoneNumberGrid_ItemDataBound
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore) _uiPhoneNumberGrid_ItemDataBound
(custom - ignore) paintPanel **********
ViewState["CurrentTab"] set here
Page_Load **********
ViewState["CurrentTab"] != null
(custom - ignore) paintTabStrips
Page.IsPostBack == true:
OnInit
InitializeComponent
(custom - ignore) InitializeSession
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore- ignore) _uiPhoneNumberGrid_ItemCreated
(datagrid - ignore) _uiPhoneNumberGrid_ItemCreated
Page_Load **********
ViewState["CurrentTab"] == null
(custom - ignore) paintTabStrips
(custom - ignore) _uiDebtorInfoSave_Click
(custom - ignore) persistData
(custom - ignore) _uiDebtorInfoSave_Click
I am going absolutely crazy with this. This is not the only page I
have that seems to be *randomly* managing ViewState.
> Hi Frank,
>
[quoted text clipped - 4 lines]
> http://www.nikhilk.net/Project.WebDevHelper.aspx ) and inspect the
> serialized viewstate in the hidden field in the html.