Accessing value of dropdown in user control from main page

G

Guest

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.
 
G

Guest

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
 
B

bhawin13

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top