开发者

how to reset dropdown selected index serverside value from javascript?

problem is I have a date text box and a shifts drop down. When I select a date and shift I get the list of employees. dropdown has a onSelectedIndexChanged event, so employee list will be populate only if we change shifts. So for date chage I have added ajavascript to reset shift dropdown to 0 index. therefore every time when you change the date you have to select the shift too and the selectindex change event will be fired.BUT the problem is when I reset shifts dropdown from javascript it is done only in client side not in server side.So if I select dropdownt to the previous value it doesn't fire the change event but for other values it 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="Eveni开发者_如何学Gong" Value="2"/>
<asp:ListItem Text="Night" Value="3"/>
</asp:DropDownList>

function ResetShifts() {
        document.getElementById('<%= ddlShifts.ClientID %>').selectedIndex = 0;
        }


You could just call the select onchange event manually

 document.getElementById('<%= ddlShifts.ClientID %>').onchange();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜