473,403 Members | 2,359 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,403 software developers and data experts.

LoadViewState not firing

I am having difficulty in diagnosing this problem and was throwing it out
for some other eyes.

I have derived my own Page class from System.Web.UI.Page and have overridden
the LoadViewState method. I derive all of my application pages from my own
Page.

For some reason on two of my pages the LoadViewState derived method is not
firing and thus not setting up some of my controls on the page. On the
other 240 ish pages, the LoadViewState method is running properly.

Interesting though, one time during the debugger it did LoadViewState, but
it seemed to only be a fluke because it didn't work the next time in debug
mode. ( no code changes )

What are some of the reasons that would cause the LoadViewState method to
not fire? I have checked and the postback page request is being correctly
identified as a postback. EnableViewState is also set to true.

TIA,

bill

1.1 .Net framework
Nov 18 '05 #1
5 1733
I have turned on tracing for the page and it is listing the LoadViewState in
the trace information, but it is not calling the overridden method on this
page only.

Any ideas?

bill
"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
I am having difficulty in diagnosing this problem and was throwing it out
for some other eyes.

I have derived my own Page class from System.Web.UI.Page and have overridden the LoadViewState method. I derive all of my application pages from my own Page.

For some reason on two of my pages the LoadViewState derived method is not
firing and thus not setting up some of my controls on the page. On the
other 240 ish pages, the LoadViewState method is running properly.

Interesting though, one time during the debugger it did LoadViewState, but
it seemed to only be a fluke because it didn't work the next time in debug
mode. ( no code changes )

What are some of the reasons that would cause the LoadViewState method to
not fire? I have checked and the postback page request is being correctly
identified as a postback. EnableViewState is also set to true.

TIA,

bill

1.1 .Net framework

Nov 18 '05 #2
Are you calling the Base class's LoadViewState in your override?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
I am having difficulty in diagnosing this problem and was throwing it out
for some other eyes.

I have derived my own Page class from System.Web.UI.Page and have overridden the LoadViewState method. I derive all of my application pages from my own Page.

For some reason on two of my pages the LoadViewState derived method is not
firing and thus not setting up some of my controls on the page. On the
other 240 ish pages, the LoadViewState method is running properly.

Interesting though, one time during the debugger it did LoadViewState, but
it seemed to only be a fluke because it didn't work the next time in debug
mode. ( no code changes )

What are some of the reasons that would cause the LoadViewState method to
not fire? I have checked and the postback page request is being correctly
identified as a postback. EnableViewState is also set to true.

TIA,

bill

1.1 .Net framework

Nov 18 '05 #3
Hi Kevin...haven't heard from you in a while.

Here is my relevant code from my derived page:

public class SqlPage : System.Web.UI.Page
{
protected override void LoadViewState( object savedState )
{
base.LoadViewState( savedState );
_Builder = ( SqlProcedureBuilder ) ViewState[
SqlProcedureBuilder.GetGuid() ];
if ( _Builder == null )
_Builder = new SqlProcedureBuilder();

_Builder.ConnectionString = SqlConnectionString;
}
protected override object SaveViewState()
{
//if ( !Builder.IsEmpty ) ************* <---
ViewState[ SqlProcedureBuilder.GetGuid() ] = _Builder;
return base.SaveViewState();
}
}
********
When I comment the line out, the derived classes LoadViewState is called, or
when the Builder is NOT empty it works. It seems ( I am probably wrong)
that if I don't adjust the ViewState in the SaveViewState method, the
LoadViewState method will not be called on the following postback.

bill
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eG**************@TK2MSFTNGP09.phx.gbl...
Are you calling the Base class's LoadViewState in your override?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
I am having difficulty in diagnosing this problem and was throwing it out for some other eyes.

I have derived my own Page class from System.Web.UI.Page and have

overridden
the LoadViewState method. I derive all of my application pages from my

own
Page.

For some reason on two of my pages the LoadViewState derived method is not firing and thus not setting up some of my controls on the page. On the
other 240 ish pages, the LoadViewState method is running properly.

Interesting though, one time during the debugger it did LoadViewState, but it seemed to only be a fluke because it didn't work the next time in debug mode. ( no code changes )

What are some of the reasons that would cause the LoadViewState method to not fire? I have checked and the postback page request is being correctly identified as a postback. EnableViewState is also set to true.

TIA,

bill

1.1 .Net framework


Nov 18 '05 #4
Hi Bill,

I'm wondering if the SaveViewState may be erroring out, causing the
ViewState not to load. You might try putting a try/catch in there, and using
the Finally block to load the base's ViewState. It is possible that you may
be experiencing a null reference error in that method (if _Builder is null).

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:uW*************@tk2msftngp13.phx.gbl...
Hi Kevin...haven't heard from you in a while.

Here is my relevant code from my derived page:

public class SqlPage : System.Web.UI.Page
{
protected override void LoadViewState( object savedState )
{
base.LoadViewState( savedState );
_Builder = ( SqlProcedureBuilder ) ViewState[
SqlProcedureBuilder.GetGuid() ];
if ( _Builder == null )
_Builder = new SqlProcedureBuilder();

_Builder.ConnectionString = SqlConnectionString;
}
protected override object SaveViewState()
{
//if ( !Builder.IsEmpty ) ************* <---
ViewState[ SqlProcedureBuilder.GetGuid() ] = _Builder;
return base.SaveViewState();
}
}
********
When I comment the line out, the derived classes LoadViewState is called, or when the Builder is NOT empty it works. It seems ( I am probably wrong)
that if I don't adjust the ViewState in the SaveViewState method, the
LoadViewState method will not be called on the following postback.

bill
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eG**************@TK2MSFTNGP09.phx.gbl...
Are you calling the Base class's LoadViewState in your override?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
I am having difficulty in diagnosing this problem and was throwing it out for some other eyes.

I have derived my own Page class from System.Web.UI.Page and have

overridden
the LoadViewState method. I derive all of my application pages from my
own
Page.

For some reason on two of my pages the LoadViewState derived method is not firing and thus not setting up some of my controls on the page. On
the other 240 ish pages, the LoadViewState method is running properly.

Interesting though, one time during the debugger it did LoadViewState,

but it seemed to only be a fluke because it didn't work the next time in debug mode. ( no code changes )

What are some of the reasons that would cause the LoadViewState method to not fire? I have checked and the postback page request is being correctly identified as a postback. EnableViewState is also set to true.

TIA,

bill

1.1 .Net framework



Nov 18 '05 #5
Kevin,

I have checked through debugger and no exceptions are through and the
accessor for the Builder will check _Builder and create if null.

When I change the SaveViewState method to

ViewState["Bob"] = new object();
return base.SaveViewState();

The LoadViewState is always called.

I am leaning more and more to the LoadViewState method is not called on the
page when the page doesn't put anything into viewstate regardless if any of
the contained controls have viewstate. (which they do.)

Thanks,

bill
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eN****************@TK2MSFTNGP09.phx.gbl...
Hi Bill,

I'm wondering if the SaveViewState may be erroring out, causing the
ViewState not to load. You might try putting a try/catch in there, and using the Finally block to load the base's ViewState. It is possible that you may be experiencing a null reference error in that method (if _Builder is null).
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:uW*************@tk2msftngp13.phx.gbl...
Hi Kevin...haven't heard from you in a while.

Here is my relevant code from my derived page:

public class SqlPage : System.Web.UI.Page
{
protected override void LoadViewState( object savedState )
{
base.LoadViewState( savedState );
_Builder = ( SqlProcedureBuilder ) ViewState[
SqlProcedureBuilder.GetGuid() ];
if ( _Builder == null )
_Builder = new SqlProcedureBuilder();

_Builder.ConnectionString = SqlConnectionString;
}
protected override object SaveViewState()
{
//if ( !Builder.IsEmpty ) ************* <---
ViewState[ SqlProcedureBuilder.GetGuid() ] = _Builder;
return base.SaveViewState();
}
}
********
When I comment the line out, the derived classes LoadViewState is called,
or
when the Builder is NOT empty it works. It seems ( I am probably wrong)
that if I don't adjust the ViewState in the SaveViewState method, the
LoadViewState method will not be called on the following postback.

bill
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eG**************@TK2MSFTNGP09.phx.gbl...
Are you calling the Base class's LoadViewState in your override?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
> I am having difficulty in diagnosing this problem and was throwing
it out
> for some other eyes.
>
> I have derived my own Page class from System.Web.UI.Page and have
overridden
> the LoadViewState method. I derive all of my application pages from my own
> Page.
>
> For some reason on two of my pages the LoadViewState derived method
is not
> firing and thus not setting up some of my controls on the page. On the > other 240 ish pages, the LoadViewState method is running properly.
>
> Interesting though, one time during the debugger it did

LoadViewState, but
> it seemed to only be a fluke because it didn't work the next time in

debug
> mode. ( no code changes )
>
> What are some of the reasons that would cause the LoadViewState
method to
> not fire? I have checked and the postback page request is being

correctly
> identified as a postback. EnableViewState is also set to true.
>
> TIA,
>
> bill
>
> 1.1 .Net framework
>
>



Nov 18 '05 #6

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

Similar topics

0
by: Christian | last post by:
Hi, I have a Webform with 1 submit button and 1 label code behind : public class MainWebForm: System.Web.UI.Page { protected System.Web.UI.WebControls.Label lblFName; protected override...
0
by: Christian | last post by:
Hi, I have a Webform with 1 submit button and 1 label code behind : public class MainWebForm: System.Web.UI.Page { protected System.Web.UI.WebControls.Label lblFName; protected override...
0
by: SSW | last post by:
Hi: In aspx.cs page i had written the code below. I only have TextBox and Button Control. LoadViewStateis Never called But when we put datagrid/DataList It works. Can any one, please tell where...
2
by: SSW | last post by:
Hi: In aspx.cs page i had written the code below. I have a button control and only create TextBox Control dynamically. LoadViewState is Never called. But when we put datagrid/DataList it...
5
by: William F. Robertson, Jr. | last post by:
I am having difficulty in diagnosing this problem and was throwing it out for some other eyes. I have derived my own Page class from System.Web.UI.Page and have overridden the LoadViewState...
2
by: Devin Fensterheim | last post by:
Does anyone know of an issue with a control's viewstate not persisting when dynamically adding custom controls to a web form using AddAt? If a control is added to an HTML form directly using the...
0
by: Ferret | last post by:
I've found what seems to be a nasty bug in the DataGrid and Repeater classes. If CreateChildControls gets called before LoadViewState, ViewState fails to map and you end up with nothing on a...
0
by: J. | last post by:
Hello, I'm trying to override the LoadViewState-method of a simple page using the .NET Framework 2.0. However, the LoadViewState-method in the code below never gets executed. The...
3
by: Peter Rilling | last post by:
Okay, I am probably missing something simple so here is my problem. I have a page. On this page I have a usercontrol. On this user control I have another usercontrol. On each usercontrol I...
0
by: Anand Saha | last post by:
In case you are creating your own control dynamically and need to re-create them on LoadViewState, only to discover that this function is not being called by the framework, reason and...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.