Tammu
asked on
access dropdownlists in a user control from a content page
Hi All,
i have a user control called MyMenu.ascx. In it i have 2 dropdownlist boxes. one is depending on the other. what i mean is the firt dropdown box has text like ALL, Men, Women and the second DDL has ALL, S, M, XL, XXL.
basically if i select one item in the first DDL ( say i select Men) then the second DDL displays all the available options for Men. here is the code for both the DDL in MyMenu.ascx
<div style="float: left; margin-left: 2px;">
<span class="text">View By Gender:</span><br />
<asp:dropdownlist id="DDLgender" runat="server" autopostback="true">
<asp:listitem value="-1">All</asp:listit em>
<asp:listitem value="1">Men</asp:listite m>
<asp:listitem value="2">Women</asp:listi tem>
</asp:dropdownlist><br />
<br />
<span class="text" style="margin-left: 2px;">View by Size:</span><br />
<asp:dropdownlist id="DDLsizes" runat="server" autopostback="true">
<asp:listitem value="-1">All</asp:listit em>
</asp:dropdownlist>
</div>
now what i want is , how can i access the first and second DDL selected values in content page. i am hope i am clear in explaining.
Thanks I appreciate it
i have a user control called MyMenu.ascx. In it i have 2 dropdownlist boxes. one is depending on the other. what i mean is the firt dropdown box has text like ALL, Men, Women and the second DDL has ALL, S, M, XL, XXL.
basically if i select one item in the first DDL ( say i select Men) then the second DDL displays all the available options for Men. here is the code for both the DDL in MyMenu.ascx
<div style="float: left; margin-left: 2px;">
<span class="text">View By Gender:</span><br />
<asp:dropdownlist id="DDLgender" runat="server" autopostback="true">
<asp:listitem value="-1">All</asp:listit
<asp:listitem value="1">Men</asp:listite
<asp:listitem value="2">Women</asp:listi
</asp:dropdownlist><br />
<br />
<span class="text" style="margin-left: 2px;">View by Size:</span><br />
<asp:dropdownlist id="DDLsizes" runat="server" autopostback="true">
<asp:listitem value="-1">All</asp:listit
</asp:dropdownlist>
</div>
now what i want is , how can i access the first and second DDL selected values in content page. i am hope i am clear in explaining.
Thanks I appreciate it
ASKER
Hello Sir,
Thanks for replying back, one newbie question: i have declared the above public strings in the user control and put a breakpoint at
get { return DDLgender.SelectedValue; }
to see if the selected value is getting passed to the string. when i ran page it does not hit the breakpoint, nothing is getting passed.
can you please tell me where i am making the mistake sir
Thanks one again
Thanks for replying back, one newbie question: i have declared the above public strings in the user control and put a breakpoint at
get { return DDLgender.SelectedValue; }
to see if the selected value is getting passed to the string. when i ran page it does not hit the breakpoint, nothing is getting passed.
can you please tell me where i am making the mistake sir
Thanks one again
It will never hit the breakpoint unless you try to access the value from your page.
ex.
protected void Page_Load(object sender, EventArgs e)
{
//Where 'menu' is the id for your custom control
string x = menu.GenderSelectedValue;
}
ex.
protected void Page_Load(object sender, EventArgs e)
{
//Where 'menu' is the id for your custom control
string x = menu.GenderSelectedValue;
}
ASKER
Ok Sir,
i have one more question, the content page where i want to access these DDL values is based on nested master page. the user control where the DDL are is in the parent master page. so how can i access the DDL values from the content page by the below code
string x = menu.GenderSelectedValue;
if i try that i cant find MyMenu (which is the user control)
any advice or sample sir.
Thanks once again i appreciate it.
i have one more question, the content page where i want to access these DDL values is based on nested master page. the user control where the DDL are is in the parent master page. so how can i access the DDL values from the content page by the below code
string x = menu.GenderSelectedValue;
if i try that i cant find MyMenu (which is the user control)
any advice or sample sir.
Thanks once again i appreciate it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks once again
public string GenderSelectedValue
{
get { return DDLgender.SelectedValue; }
}
public string SizesSelectedValue
{
get { return DDLsizes.SelectedValue; }
}