Access to parent objects

Discussion in 'ASP .Net' started by SOS, May 2, 2004.

  1. SOS

    SOS Guest

    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 :)
     
    SOS, May 2, 2004
    #1
    1. Advertising

  2. SOS

    Teemu Keiski Guest

    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" <> wrote in message
    news:...
    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 :)
     
    Teemu Keiski, May 2, 2004
    #2
    1. Advertising

  3. SOS

    Rick Spiewak Guest

    All web controls inherit a .Parent property.

    "SOS" <> wrote in message
    news:...
    > 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 :)
    >
    >
     
    Rick Spiewak, May 3, 2004
    #3
  4. SOS

    SOS Guest

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


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

    >
    >
     
    SOS, May 3, 2004
    #4
  5. SOS

    Rick Spiewak Guest

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

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

    > >
    > >

    >
    >
     
    Rick Spiewak, May 4, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roy
    Replies:
    2
    Views:
    3,173
  2. mark
    Replies:
    1
    Views:
    600
  3. 7stud
    Replies:
    11
    Views:
    756
    Dennis Lee Bieber
    Mar 20, 2007
  4. Rob Mayo

    Access parent Page's objects from Custom Control

    Rob Mayo, Jul 3, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    144
    Rob Mayo
    Jul 3, 2003
  5. Bitswapper
    Replies:
    5
    Views:
    185
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page