Desperate repost: Reloading page too quickly results in an error

W

Walter

Each of the aspx pages in my application have a User Control called
"WrapStart".

In a page's Page_Load() method, I set various properties and/or call
various methods of the WrapStart control object. Everything works
fine... except...

....when I click too quickly from one page to another (or quickly
reload the same page). When I do, I get the following error:

"Object reference not set to an instance of an object."

And the line highlighted in the error is: WrapStart.someMethod();


I'm wondering what is going on and how do I fix this problem. Any
help would be greatly appreciated.
 
H

Hermit Dave

Have you tried setting the user control as an data member within your
derived class (ie the custom page)
or are you relying on Page.FindControl to get its instance ?

I think declaring it as a data member should ease the problem cause it will
be initialised and bound correctly in the constructor

public class CA_ShowProductStock : System.Web.UI.Page
{
protected System.Web.UI.WebControls.LinkButton lnkBack;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected WebShop.ShopAdmin.Label ModuleTitle1;

The html view on the aspx file has the user control id as ModuleTitle1.
Let us know how you get on with it...

Hope this helps,

HD
 
W

Walter

This is the way it already is accessed.

Hermit Dave said:
Have you tried setting the user control as an data member within your
derived class (ie the custom page)
or are you relying on Page.FindControl to get its instance ?

I think declaring it as a data member should ease the problem cause it will
be initialised and bound correctly in the constructor

public class CA_ShowProductStock : System.Web.UI.Page
{
protected System.Web.UI.WebControls.LinkButton lnkBack;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected WebShop.ShopAdmin.Label ModuleTitle1;

The html view on the aspx file has the user control id as ModuleTitle1.
Let us know how you get on with it...

Hope this helps,

HD
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top