accessing aspx control from ascx

Discussion in 'ASP .Net' started by rom, Nov 22, 2004.

  1. rom

    rom Guest

    Hi,

    I have an aspx page with header as user control, footer as
    user control, and 2 other user controls inside the page.

    I'm trying to access a seleted value of a dropdownlist the
    exists in the main aspx page from one of the user
    controls. I know it's possible because I reached it by
    using debug and it exists with the value in here:

    directcast(page.controls(3).controls
    (19),dropdownlist).selectedvalue

    but, of course, this is not a way to solve things....
    How can I do this correctly?

    Thanks.
     
    rom, Nov 22, 2004
    #1
    1. Advertising

  2. > I'm trying to access a seleted value of a dropdownlist the
    > exists in the main aspx page from one of the user
    > controls. I know it's possible because I reached it by
    > using debug and it exists with the value in here:


    You can access the controls on the page via the Page property of the
    UserControl like this:
    Control control=Page.FindControl("MyControl");

    However, I suggest that you redesign your application because UserControls
    should not depend on controls in it's container (Page in your example).

    Anders Norås
    blog: http://dotnetjunkies.com/weblog/anoras/
     
    Anders Norås, Nov 22, 2004
    #2
    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. Quentin
    Replies:
    1
    Views:
    497
    Quentin
    Jul 29, 2003
  2. Jason Shohet
    Replies:
    1
    Views:
    488
    Kevin Spencer
    Nov 10, 2003
  3. Holger (David) Wagner
    Replies:
    2
    Views:
    1,955
    Holger (David) Wagner
    Jul 3, 2004
  4. Martin Eyles

    accessing .ascx data from .aspx

    Martin Eyles, Jan 17, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    11,060
    Martin Eyles
    Jan 19, 2006
  5. rom

    accessing aspx object from ascx pages and vise verce?

    rom, Nov 22, 2004, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    199
    John Saunders
    Nov 23, 2004
Loading...

Share This Page