c# - get the value of dropdown on asp button click -
i'm trying populate on dropdown(i.e dropdown2) on value basis of other dropdown(i.e dropdown1), it's populate fine,now problem when i'm click on asp button selected value of dropdown 2 return blank value, i'm not not understand going wrong?
html
<select runat="server" id="ddlfilter" clientidmode="static"> <option value="0">both</option> <option value="1">add new</option> <select runat="server" id="ddldepartment" clientidmode="static"></select> <asp:button id="btnsearch" runat="server" text="show report" cssclass="search_btn" onclick="btnsearch_click" /> js
<script> $(document).ready(function () { $("#ddlfilter").change(function () { if ($("#ddlfilter").val() > 0) { $("#ddldepartment").append( < option > new < option > ); } }); }); </script> c#
protected void btnsearch_click(object sender, eventargs e) { string val= ddldepartment.value; }
you can't selected value dropdown if adding options in javascript. can use:
string selectedvalue = request.form[ddldepartment.uniqueid]; see question
Comments
Post a Comment