I created an ASP.NET website. I want to make the label change its contents depending on the item selected in the drop-down list. I tried this, but this did not work:
The dropdown list is as follows:
<asp:DropDownList ID="DropDown1" runat="server" > <asp:ListItem Value="a"></asp:ListItem> <asp:ListItem Value="b"></asp:ListItem> onselectedindexchanged="DropDown1_SelectedIndexChanged" </asp:DropDownList>
label:
<asp:Label ID="Label1" Text="" runat="server"/>
I want to do this without using PostBack .
I tried using the ajax Refresh panel.
<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger controlid="DropDown1" EventName="SelectedIndexChanged" /> </Triggers> <ContentTemplate> <asp:Label ID="Label1" Text="" runat="server"/> </ContentTemplate> </asp:UpdatePanel>
And in the DropDown1_SelectedIndexChanged event in the codec :
protected void DropDown1_SelectedIndexChanged(object sender, EventArgs e) { Label1.Text = DropDown1.SelectedValue; }
But that does not work.
Can anybody help me?
Thanks so much for any help
source share