Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

ViewState timing driving me nuts - please help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank - 16 Feb 2006 06:38 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.