Hi Nikhil,
You can insert the client-side code from the code-behind and add an
attribute to the DDL. Here's some code, let us know if it helps?
Ken
Microsoft MVP [ASP.NET]
Toronto
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load
Page.RegisterClientScriptBlock("hndlr","<scr" + "ipt
language=JavaScript>function change_handler(){alert('Got a
change!');return
false;}</sc" + "ript>")
DropDownList1.attributes.add("onchange","change_handler()")
end sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp
ropDownList id="DropDownList1" runat="server">
<asp:ListItem Value="Red">Red</asp:ListItem>
<asp:ListItem Value="Green">Green</asp:ListItem>
<asp:ListItem Value="Blue">Blue</asp:ListItem>
</asp
ropDownList>
</form>
</body>
</html>
Nikhil Patel said:
Hi all,
Is it possible to add two lines of javascript code from code behind at
runtime and link it to a DropDown control's SelectedIndexChanged event?
Thanks.
-Nikhil