考虑下面的代码:如何通过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