I would like to add Javascript code to be fired when the selected index is changed on a dropdownlist in asp.net.
So, here is my DDL:
<asp:DropDownList ID="comboReportTypes" runat="server" />
I would like to add something like this to the above DDL: onSelectionIndexChanged=”MyJavascriptFuntion(this)”
So I’d like to end up with something like this:
<asp:DropDownList ID="comboReportTypes" runat="server" onSelectionIndexChanged="MyJavascriptFuntion(this)" />
Is this possible?
Thanks in advance. I’m using ASP.Net 4.0
add onchange event to it from the code .
Eg:
DropDownList dlOption = new DropDownList();
dlOption.Attributes.Add(“onchange”, “javascript:return functionname(this);”);