Hi this is venkat,
i have a drop downlist for country, i composed a code in javascript for that and its working in HTML page but i dont know how to call the same javascript function in asp.net(C#) dropdownlist. please advice me and send me code for how to call the function..
Hi Venkat :)
JavaScript works in the browser (client side).
Your C# code works on the web server (server side).
You cannot call JavaScript functions from your C# code.
What you can do is set each of your DropDownList Items to have an "onclick" event:
-
foreach(ListItem i in MyCountryDropDownList.Items)
-
{ i.Attributes.Add("onclick","theJavaScriptFunction();");}
-
This will cause the JavaScript function to be called when ever the DropDownList item has be clicked on.
If you need your C# code to generate your country list on the server, then you must implement this in C#. You cannot call your JavaScript function from the server.
-Frinny