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.