1

I have a dropdownlist control on masterpage in asp.net. as follows:

<asp:DropDownList ID="ddladults" runat="server" CssClass="input_bg">
      <asp:ListItem Value="0">----Select----</asp:ListItem>
      <asp:ListItem Value="1">1</asp:ListItem>
      <asp:ListItem Value="2">2</asp:ListItem>
      <asp:ListItem Value="3">3</asp:ListItem>
      <asp:ListItem Value="4">4</asp:ListItem>
      <asp:ListItem Value="5">5</asp:ListItem>
      <asp:ListItem Value="6">6</asp:ListItem>
      <asp:ListItem Value="7">7</asp:ListItem>
      <asp:ListItem Value="8">8</asp:ListItem>
      <asp:ListItem Value="9">9</asp:ListItem>
      <asp:ListItem Value="10">10</asp:ListItem>
</asp:DropDownList>

Here I want to pass the selected value to the content page named Checkavailablity.aspx.

Please give your ideas.

1 Answer 1

6

To get master page control values in content page, use Master.FindControl().

Add the following code in the Content Page.

Code

DropDownList masterDropDown = (DropDownList)Master.FindControl("ddladults");
String selectedValue=masterDropDown.SelectedItem.Text.ToString();

OR

DropDownList masterDropDown = (DropDownList)Master.FindControl("ddladults");
String selectedValue=masterDropDown.SelectedValue.ToString();


Then use that String selectedValue for whatever you want to do with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.