Asp.net 使用UpdatePanel进行部分页面刷新
我有一个与母版页关联的页面。我需要实现Ajax(基本上是想进行部分页面刷新)。 在这个页面中,我有网格和分页按钮(first/previous/last/next)、下拉列表和搜索。 所有这些都会更新网格 现在我有下面的代码Asp.net 使用UpdatePanel进行部分页面刷新,asp.net,updatepanel,asp.net-4.0,Asp.net,Updatepanel,Asp.net 4.0,我有一个与母版页关联的页面。我需要实现Ajax(基本上是想进行部分页面刷新)。 在这个页面中,我有网格和分页按钮(first/previous/last/next)、下拉列表和搜索。 所有这些都会更新网格 现在我有下面的代码 <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> 在 以下是类似html的网格/按钮/ContentTemplate标记启动后的搜索 最后,页面
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
在
以下是类似html的网格/按钮/ContentTemplate标记启动后的搜索
最后,页面留下了菜单/页脚/页眉和内容
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
但这仍然是一个令人耳目一新的页面。我对你拥有的和你想要的有点困惑 听起来您有一个
内容
控件,其中有一个更新面板
。在UpdatePanel
ContentTemplate
中,您的菜单中有所有的网格、按钮等
您只需要在UpdatePanel
ContentTemplate
中设置要刷新的控件。除了UpdatePanel
之外,您应该拥有的所有其他内容。如果在UpdatePanel
之外有任何控件,则需要为UpdatePanel
中的每个控件设置一个trigger
来触发刷新,并告诉它要触发哪个事件
例如:
<asp:Button ID="btnTest" runat="server" Text="Test" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<!-- only your content that needs refreshing goes here -->
<ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnTest" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
我对你拥有的东西和你想要的东西有点困惑
听起来您有一个内容
控件,其中有一个更新面板
。在UpdatePanel
ContentTemplate
中,您的菜单中有所有的网格、按钮等
您只需要在UpdatePanel
ContentTemplate
中设置要刷新的控件。除了UpdatePanel
之外,您应该拥有的所有其他内容。如果在UpdatePanel
之外有任何控件,则需要为UpdatePanel
中的每个控件设置一个trigger
来触发刷新,并告诉它要触发哪个事件
例如:
<asp:Button ID="btnTest" runat="server" Text="Test" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<!-- only your content that needs refreshing goes here -->
<ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnTest" EventName="Click" />
</Triggers>
</asp:UpdatePanel>