Access to parent objects

  • Thread starter Thread starter SOS
  • Start date Start date
S

SOS

Hi guys ,
i create a custom control and place it on a web form,
how can i access to this web form from my custom control ?

for example i want to add a button to this webform by writing code in my
custom control.

Thanx :)
 
Hi,

via Page property of your control (which it has by default) you can access
the top-level Page object from which you can search child controls with
FindControl method.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


Hi guys ,
i create a custom control and place it on a web form,
how can i access to this web form from my custom control ?

for example i want to add a button to this webform by writing code in my
custom control.

Thanx :)
 
Thanks
but when i use of this property in my class constructer
i get this error : Object reference not set to ...
 
The parent won't exist until you add your control to the page's or form's
controls collection.
 
Back
Top