Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Access to parent objects

Reply
Thread Tools

Access to parent objects

 
 
SOS
Guest
Posts: n/a
 
      05-02-2004
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


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      05-02-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
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



 
Reply With Quote
 
 
 
 
Rick Spiewak
Guest
Posts: n/a
 
      05-03-2004
All web controls inherit a .Parent property.

"SOS" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
SOS
Guest
Posts: n/a
 
      05-03-2004
Thanks
but when i use of this property in my class constructer
i get this error : Object reference not set to ...


"Rick Spiewak" <(E-Mail Removed)> wrote in message
news:eDvPr$(E-Mail Removed)...
> All web controls inherit a .Parent property.
>
> "SOS" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Rick Spiewak
Guest
Posts: n/a
 
      05-04-2004
The parent won't exist until you add your control to the page's or form's
controls collection.

"SOS" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks
> but when i use of this property in my class constructer
> i get this error : Object reference not set to ...
>
>
> "Rick Spiewak" <(E-Mail Removed)> wrote in message
> news:eDvPr$(E-Mail Removed)...
> > All web controls inherit a .Parent property.
> >
> > "SOS" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If a class Child inherits from Parent, how to implementChild.some_method if Parent.some_method() returns Parent instance ? metal Python 8 10-30-2009 10:31 AM
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
Parent - Child back to parent javascript thingybob mark ASP .Net 1 03-10-2005 02:20 PM
What does sender.Parent.Parent.Cells() reference? Frustrating... Roy ASP .Net 2 02-11-2005 09:00 PM
Access parent Page's objects from Custom Control Rob Mayo ASP .Net Web Controls 0 07-03-2003 01:59 AM



Advertisments