Click here to Skip to main content
16,016,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have this
HTML
<script type="text/javascript">  setState(this);</script>

and dropdownlist in source code of .net page
ASP.NET
<asp:DropDownList  ID="ddlState" runat="server" CssClass="input2" style="width:196px" onchange="set_city_state(this,district)">
	 <asp:ListItem Value="" Selected="True">Select State</asp:ListItem>
	 
          </asp:DropDownList>


but i don't know how to relate both so that drop down bind with data written in javascript..
Posted

1 solution

The function name written in the on change event must be equal to the function written in the java script so that when the event fire it will go to that function written in the java script file.

ASP.NET
<asp:dropdownlist id="ddlState" runat="server" cssclass="input2" style="width:196px" onchange="setState(this,district)" xmlns:asp="#unknown">
	 <asp:listitem value="" selected="True">Select State</asp:listitem>
	 
          </asp:dropdownlist>
 
Share this answer
 
Comments
pck.ns 18-May-12 4:18am    
data is not binding.tell me how to relate first code with 2nd one.both code were related to each other in html page as
<select class="input input2" style="width:196px" önchange="set_city_state(this,district)">
<option value="" selected="selected">Select State</option><script type="text/javascript">setState(this);</script></select>

but when i converted that html page in aspx problem is created.
bhagirathimfs 18-May-12 4:33am    
Inside setstate function you have written code to bind the drop down??
If yes than use onload event rather than onchange event.
If no than what is the java script function namein which you have written the bind code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900