Desperate repost: Reloading page too quickly results in an error

  • Thread starter Thread starter Walter
  • Start date Start date
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.
 
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
 
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
 
Back
Top