Reputation: 317
is there a way to do onChange event for <selec>
in asp.net?
i have tried
protected void Status_Change(object sender, EventArgs e)
EDIT: the problem:
code behind:
protected void Status_SelectedIndexChanged(object sender, EventArgs e)
{
this.Label1.Text = "ok";
}
html:
<form id="form2" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<select id="Status" name="Status" class="regis" style="width:170px" onselectedindexchanged="Status_SelectedIndexChanged">
<option value="0">1</option>
<option value="1">2</option>
</select>
</form>
why doesnt it work? tnx for the help :D
Upvotes: 0
Views: 6314
Reputation: 311
Replace
<select id="Status" name="Status" class="regis" style="width:170px" onselectedindexchanged="Status_SelectedIndexChanged">
<option value="0">1</option>
<option value="1">2</option>
</select>
by
<asp:DropDownList ID="Status" runat="server" Width="200px" onselectedindexchanged="Status_SelectedIndexChanged">
<asp:ListItem Value="0">1</asp:ListItem>
<asp:ListItem Value="1">2</asp:ListItem>
</asp:DropDownList>
Upvotes: 0
Reputation: 2542
Please add runat="server"
like following:
<select id="Status" name="Status" class="regis" style="width:170px" onselectedindexchanged="Status_SelectedIndexChanged" runat="server">
Upvotes: 1
Reputation: 9947
<asp:DropDownList ID="ddlselect" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlselect_Changed">
</asp:DropDownList>
In Code Behind
protected void ddlselect_Changed(object sender, EventArgs e)
{
}
Upvotes: 0