考慮下面的代碼:如何通過TextBox控件觸發UpdatePanel?
<label>Search:</label><asp:TextBox runat="server" ID="search" ClientIDMode="Static" OnKeyUp="$('#searchButton').click();" /><asp:Button runat="server" ID="searchButton" ClientIDMode="Static" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView runat="server" DataSourceID="EntityDataSource1"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="true" PageSize="20"
Width="400" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="searchButton" />
</Triggers>
</asp:UpdatePanel>
該按鈕將觸發面板的更新。我想通過搜索字段的關鍵字來觸發更新,所以我用一個單擊按鈕的jQuery語句「僞裝」它。我想知道...必須有更好的方式......對!
可能這會幫助你 http://stackoverflow.com/questions/1009086/how-to-make-an-asp-net-textbox-fire-its-ontextchanged-event-fire-in-an -ajax-upd – coder
@Kiran搜索字段在更新面板之外,這使得它不同於問題1009086,因爲如果我使用自動提交,頁面將被提交。也許雷米是對的,我應該寫我自己的控制它... –
是的,我也同意。因爲我現在也在做同樣的事情可能是他的權利。 – coder