Accessing value of dropdown in user control from main page

Discussion in 'ASP .Net' started by =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=, Dec 21, 2005.

  1. I have a user control, dropdown.ascx

    Inside dropdown.ascx, I have a dropdownlist control.

    From my page.aspx, I need to be able to access the dropdown's value.

    By setting it to auto-post back, I am able to grab this value using
    Request.Form["Control:ddlValues"]. This worked well until I realized that I
    needed the initial value in some cases. How do I access this value from the
    page.aspx file?

    Thank you very much.
    =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=, Dec 21, 2005
    #1
    1. Advertising

  2. Brenden,

    1- Define an event for your control that you raise whenever the
    dropdownlist SelectedIndexChanged is handled,
    2- Define a class that holds event data (which you can customize to hold
    both the old and the new values of the dropdownlist)
    3- Define an event delegate so that your page.aspx can subscribe to it and
    collect the old and new values from your customized eventargs.

    For a demo on this strategy:
    http://www.societopia.net/Samples/DataGrid_ChildControlsEvents.aspx
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Brenden Bixler" wrote:

    > I have a user control, dropdown.ascx
    >
    > Inside dropdown.ascx, I have a dropdownlist control.
    >
    > From my page.aspx, I need to be able to access the dropdown's value.
    >
    > By setting it to auto-post back, I am able to grab this value using
    > Request.Form["Control:ddlValues"]. This worked well until I realized that I
    > needed the initial value in some cases. How do I access this value from the
    > page.aspx file?
    >
    > Thank you very much.
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Dec 22, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=

    bhawin13 Guest

    Hello Brenden Bixler

    Simplest thing is to declare your list box public. So you can access it
    from your page.
    If you will do this you dont need to write any extra wrapper methods.

    Correct me If I am wrong.
    B
    bhawin13, Dec 22, 2005
    #3
    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. Reny J Joseph Thuthikattu
    Replies:
    1
    Views:
    547
    =?Utf-8?B?UHJha2FzaC5ORVQ=?=
    Dec 30, 2004
  2. vishnu
    Replies:
    1
    Views:
    1,191
    Patrick.O.Ige
    Mar 25, 2006
  3. Kiran More
    Replies:
    2
    Views:
    308
    Kiran More
    Nov 14, 2006
  4. hourman
    Replies:
    2
    Views:
    121
    hourman
    Jul 21, 2003
  5. Robert Oschler
    Replies:
    1
    Views:
    384
Loading...

Share This Page