ViewState timing driving me nuts - please help

F

Frank

Can someone please tell me when the ViewState is loaded? My
understanding, based on
http://msdn.microsoft.com/library/d...guide/html/cpconControlExecutionLifecycle.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
 
F

Frank

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
}
 
F

Frank

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
Jason said:
Have u ensured that the viewstate property on the control is set to True?

Frank said:
Can someone please tell me when the ViewState is loaded? My
understanding, based on
http://msdn.microsoft.com/library/d...guide/html/cpconControlExecutionLifecycle.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
 
F

Frank

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top