views:

15

answers:

1

Hi,

I have a dropdown inside a webusercontrol which I want to use on 5 pages. I want to save the selected value of the dropdown from the page.

I tried to access it using below method, but its not working

http://stackoverflow.com/questions/2367957/finding-and-accessing-elements-of-a-webusercontrol

on webPage its not don't show the method to get the selected Value

Regards

+1  A: 

As that answer shows you should create a method in your user control that exposes the selected value of your dropdown that resides within your user control.

In your WebUserControl (user control) code-behind file, you could have something like this:

public string DropDownSelectedValue
{
    get
    {
       return dropDown.SelectedValue;
    }
}

Now on your web page where you're using that user control, you should call that property like this:

// Assuming you defined your usercontrol with the 'yourUserControl' ID
string selectedValue = yourUserControl.DropDownSelectedValue;

Make sure you rebuild your usercontrol code (project) so that this new property is available to you to use.

Leniel Macaferi