asp.net - how to reset dropdown selected index serverside value from javascript? -
problem have date
text box , shifts
drop down. when select date , shift list of employees. dropdown has onselectedindexchanged
event, employee list populate if change shifts. date chage have added ajavascript reset shift dropdown
0
index. therefore every time when change date have select shift , selectindex change event fired.but the problem when reset shifts dropdown javascript done in client side not in server side.so if select dropdownt previous value doesn't fire change event other values works fine
.
<asp:textbox id="txtselectdate" runat="server" cssclass="inputaddres" onchange="javascript:return resetshifts();"></asp:textbox> <asp:dropdownlist id="ddlshifts" autopostback="true" onselectedindexchanged="ddlshifts_selectedindexchanged" runat="server" > <asp:listitem text="morning" value="1"/> <asp:listitem text="evening" value="2"/> <asp:listitem text="night" value="3"/> </asp:dropdownlist> function resetshifts() { document.getelementbyid('<%= ddlshifts.clientid %>').selectedindex = 0; }
you call select onchange event manually
document.getelementbyid('<%= ddlshifts.clientid %>').onchange();
Comments
Post a Comment