Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts

I have a drop down and hidden field. I want to assign the selected value of Drop down in the hidden field value literal.

XML
<asp:DropDownList ID="ddlTireLn" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlTireLn_SelectedIndex"
                               DataTextField="I001TRLN" DataValueField="I001TRLN" Height="16px" Width="100%">
                            </asp:DropDownList>
                            <input type="hidden" name="TirelineSearch" value="<asp:Literal id='litTirelineSearch' runat='server' />" />



Can anyone tell me how to achieve this?
Posted

1 solution

ASP.NET
<asp:DropDownList ID="ddlTireLn" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlTireLn_SelectedIndex"
    DataTextField="I001TRLN" DataValueField="I001TRLN" Height="16px" Width="100%">
</asp:DropDownList>
<asp:HiddenField ID="TirelineSearch" runat="server" />


C#
protected void ddlTireLn_SelectedIndex(object sender, EventArgs e)
{
    TirelineSearch.Value = ddlTireLn.SelectedValue;
}
 
Share this answer
 
Comments
sudevsu 12-Mar-15 14:21pm    
I actually should use <input type="hidden" name="TirelineSearch" value="<asp:Literal id='litTirelineSearch' runat="'server'" />" />

I know that we can use ASp:Hidden.
ButI want something like above with <input>
F-ES Sitecore 12-Mar-15 14:45pm    
asp:Hidden renders as <input type="hidden"> in the source.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900