ViewState timing driving me nuts - please help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frank

    #1

    ViewState timing driving me nuts - please help

    Can someone please tell me when the ViewState is loaded? My
    understanding, based on
    http://msdn.microsoft.com/library/de...nLifecycle.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(objec t sender, System.EventArg s e)
    {
    if (Page.IsPostBac k & ViewState["CurrentTab "] != null)
    {
    _currentTab = (PageTabs)ViewS tate["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.IsPostBac k=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

    #2
    Re: ViewState timing driving me nuts - please help

    Hi Frank,

    what is the type of PageTabs?


    Frank skrev:
    [color=blue]
    > Can someone please tell me when the ViewState is loaded? My
    > understanding, based on
    > http://msdn.microsoft.com/library/de...nLifecycle.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(objec t sender, System.EventArg s e)
    > {
    > if (Page.IsPostBac k & ViewState["CurrentTab "] != null)
    > {
    > _currentTab = (PageTabs)ViewS tate["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.IsPostBac k=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[/color]

    Comment

    • Frank

      #3
      Re: ViewState timing driving me nuts - please help

      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
      }

      Comment

      • Jason Myers

        #4
        Re: ViewState timing driving me nuts - please help

        Have u ensured that the viewstate property on the control is set to True?

        "Frank" <mrpubnight@hot mail.com> wrote in message
        news:1140071909 .189282.296910@ g43g2000cwa.goo glegroups.com.. .[color=blue]
        > Can someone please tell me when the ViewState is loaded? My
        > understanding, based on
        > http://msdn.microsoft.com/library/de...nLifecycle.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(objec t sender, System.EventArg s e)
        > {
        > if (Page.IsPostBac k & ViewState["CurrentTab "] != null)
        > {
        > _currentTab = (PageTabs)ViewS tate["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.IsPostBac k=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
        >[/color]


        Comment

        • Frank

          #5
          Re: ViewState timing driving me nuts - please help

          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 Myers wrote:[color=blue]
          > Have u ensured that the viewstate property on the control is set to True?
          >
          > "Frank" <mrpubnight@hot mail.com> wrote in message
          > news:1140071909 .189282.296910@ g43g2000cwa.goo glegroups.com.. .[color=green]
          > > Can someone please tell me when the ViewState is loaded? My
          > > understanding, based on
          > > http://msdn.microsoft.com/library/de...nLifecycle.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(objec t sender, System.EventArg s e)
          > > {
          > > if (Page.IsPostBac k & ViewState["CurrentTab "] != null)
          > > {
          > > _currentTab = (PageTabs)ViewS tate["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.IsPostBac k=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
          > >[/color][/color]

          Comment

          • dnz

            #6
            Re: ViewState timing driving me nuts - please help

            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.

            Comment

            • Frank

              #7
              Re: ViewState timing driving me nuts - please help

              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
              InitializeCompo nent
              (custom - ignore) InitializeSessi on
              (custom - ignore) paintPanel
              (custom - ignore) buildPanelDebto rInfo
              (custom - ignore) bindPhoneNumber Grid
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore) _uiPhoneNumberG rid_ItemDataBou nd
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore) _uiPhoneNumberG rid_ItemDataBou nd
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore) _uiPhoneNumberG rid_ItemDataBou nd
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore) _uiPhoneNumberG rid_ItemDataBou nd
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore) _uiPhoneNumberG rid_ItemDataBou nd
              (custom - ignore) paintPanel **********
              ViewState["CurrentTab "] set here
              Page_Load **********
              ViewState["CurrentTab "] != null
              (custom - ignore) paintTabStrips

              Page.IsPostBack == true:

              OnInit
              InitializeCompo nent
              (custom - ignore) InitializeSessi on
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore- ignore) _uiPhoneNumberG rid_ItemCreated
              (datagrid - ignore) _uiPhoneNumberG rid_ItemCreated
              Page_Load **********
              ViewState["CurrentTab "] == null
              (custom - ignore) paintTabStrips
              (custom - ignore) _uiDebtorInfoSa ve_Click
              (custom - ignore) persistData
              (custom - ignore) _uiDebtorInfoSa ve_Click



              I am going absolutely crazy with this. This is not the only page I
              have that seems to be *randomly* managing ViewState.




              dnz wrote:[color=blue]
              > 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.[/color]

              Comment

              Working...