2011-05-11 44 views
0

問題是我有一個date文本框和一個shifts下拉。當我選擇一個日期和班次時,我得到了員工名單。下拉菜單中有onSelectedIndexChanged事件,因此只有在我們更改班次時纔會填充員工列表。所以對於日期chage我添加了一個JavaScript重置shift dropdown0索引。因此,每次更改日期時,您也必須選擇輪班,並且會觸發selectindex更改事件。 但是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如何重置下拉選擇索引serverside值從JavaScript?

<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

你可以只調用選擇onchange事件手動

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