Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Referencing Page object from a nested Custom Control
Message
From
22/08/2005 14:08:19
 
 
To
All
General information
Forum:
ASP.NET
Category:
Web control library
Title:
Referencing Page object from a nested Custom Control
Miscellaneous
Thread ID:
01042706
Message ID:
01042706
Views:
65
I have created an ASP.NET Custom Control which renders as a LinkButton. This control works properly when placed directly on a web form.

However, When I try to instantiate the custom LinkButton control in another Custom Control as a child control, I get the following error when the controls are rendered:

System.NullReferenceException: Object reference not set to an instance of an object.

This error occurs in the overridden Render method in the child LinkButton Custom Control. The object being referenced is the Page object in the following line of code from the Render method:
output.Write("<a  id=\"" + this.UniqueID + "\" href=\"javascript:" + this.Page.GetPostBackEventReference(this) +"\">");
For some reason the Page object is not found when the custom control is instantiated in a parent Custom Control.

Does anyone know what I am missing here and how to resolve this issue?

Thanks,
Bill
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Reply
Map
View

Click here to load this message in the networking platform