Access to parent objects

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 :)
 
T

Teemu Keiski

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 :)
 
S

SOS

Thanks
but when i use of this property in my class constructer
i get this error : Object reference not set to ...
 
R

Rick Spiewak

The parent won't exist until you add your control to the page's or form's
controls collection.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top