By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

Access to parent objects

P: n/a
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 :)
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
"SOS" <SO*@hotmail.com> wrote in message
news:O1*************@TK2MSFTNGP11.phx.gbl...
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 :)

Nov 18 '05 #2

P: n/a
All web controls inherit a .Parent property.

"SOS" <SO*@hotmail.com> wrote in message
news:O1*************@TK2MSFTNGP11.phx.gbl...
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 :)

Nov 18 '05 #3

P: n/a
SOS
Thanks
but when i use of this property in my class constructer
i get this error : Object reference not set to ...
"Rick Spiewak" <ri*********@mindspring.com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
All web controls inherit a .Parent property.

"SOS" <SO*@hotmail.com> wrote in message
news:O1*************@TK2MSFTNGP11.phx.gbl...
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 :)


Nov 18 '05 #4

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

"SOS" <SO*@hotmail.com> wrote in message
news:eM**************@TK2MSFTNGP10.phx.gbl...
Thanks
but when i use of this property in my class constructer
i get this error : Object reference not set to ...
"Rick Spiewak" <ri*********@mindspring.com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
All web controls inherit a .Parent property.

"SOS" <SO*@hotmail.com> wrote in message
news:O1*************@TK2MSFTNGP11.phx.gbl...
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 :)



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.