问题是我有一个date
文本框和一个shifts
下拉列表。当我选择日期和班次时,我会得到员工名单。下拉列表中有onSelectedIndexChanged
个事件,因此只有在我们更改班次时才会填充员工列表。所以对于日期chage,我添加了一个javascript来重置shift dropdown
到0
索引。因此,每当您更改日期时,您也必须选择班次,并且将触发selectindex change事件。但 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="Evening" Value="2"/>
<asp:ListItem Text="Night" Value="3"/>
</asp:DropDownList>
function ResetShifts() {
document.getElementById('<%= ddlShifts.ClientID %>').selectedIndex = 0;
}
答案 0 :(得分:0)
您可以手动调用select onchange事件
document.getElementById('<%= ddlShifts.ClientID %>').onchange();