473,385 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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(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

Feb 16 '06 #1
6 1261
dnz
Hi Frank,

what is the type of PageTabs?
Frank skrev:
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(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


Feb 16 '06 #2
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
}

Feb 16 '06 #3
Have u ensured that the viewstate property on the control is set to True?

"Frank" <mr********@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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(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

Feb 16 '06 #4
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:
Have u ensured that the viewstate property on the control is set to True?

"Frank" <mr********@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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(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


Feb 16 '06 #5
dnz
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.

Feb 17 '06 #6
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.


dnz wrote:
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.


Feb 20 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Keiron Waites | last post by:
Please see the problem in action here: http://www.leadbullet.biz/contact.php If you mouse over the fields, you will see that text is shown on the right. The text makes the other fields move when...
1
by: Bill | last post by:
I've been chasing this problem around for a few days now and its driving me nuts. We keep getting these errors in our web application intermittently. I can't cause the problem myself to attempt to...
12
by: Marty | last post by:
It seems all of the sudden that user controls that contain images are referencing image sources relative to the document that I drop the control on. This obviously does not work beacuase the...
0
by: Simon Harris | last post by:
Ok, this really is driving me nuts!!! :( 'All' I am trying to do is get the value of a named element. My XML doc is: <?xml version="1.0" encoding="utf-16" standalone="yes" ?> - <Page>...
4
by: trond | last post by:
Hello all, Before I start I'd like to point out that I am a complete novice when it comes to asp.net - My background is in network and operating systems, and although I have been doing a bit of...
2
by: mitsura | last post by:
Hi, I need to read a simle XML file. For this I use the SAX parser. So far so good. The XML file consist out of number of "Service" object with each object a set of attributes. I read...
2
by: julie.siebel | last post by:
Google apparently ate my original post to this (grr) so this'll be a bit more vague than the initial post, but...*sigh*. Javascript is not my forte, and I apologize for the acky-ness of the...
1
by: Sanjay Pais | last post by:
We keep getting this error on one of our web pages. I have absolutely no idea which control is causing the problem. How do i diagnose and fix this problem? It has been driving us nuts!
1
balabaster
by: balabaster | last post by:
Hi, I've been bashing my head against this since Friday and it's driving me nuts. I've got an EntitySet(Of T) (LINQ) which is serialized to/from the viewstate by overriding the LoadViewState and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.