【问题标题】:Is it normal for Page_Load to trigger upon clicking a page of a GridView inside an UpdatePanel?在 UpdatePanel 中单击 GridView 的页面时触发 Page_Load 是否正常?
【发布时间】:2011-09-01 11:02:39
【问题描述】:

我的 aspx 页面中有这段代码:

<form id="form2" runat="server">
  <asp:ScriptManager ID="ItemsScriptManager" runat="server" EnablePartialRendering="true" />
  <asp:Button runat="server" ID="SearchButton" OnClick="ItemsSearch" Text="Search" />
  <asp:UpdatePanel runat="server" ID="ItemsUpdatePanel">
    <ContentTemplate>
      <asp:ObjectDataSource runat="server" ID="ItemsDS"
        TypeName="TemplateGridViewODSPagingSorting.ItemDAO" SelectMethod="GetItems" />
      <asp:GridView runat="server" ID="ItemsGridView" DataSourceID="ItemsDS"
        AllowPaging="true" AllowSorting="true" PageSize="4">
      </asp:GridView>
    </ContentTemplate>
  </asp:UpdatePanel>
</form>

按下 GridView 的另一个页面会触发 Page_Load,这对于部分回发来说是正常行为吗?

【问题讨论】:

    标签: c# asp.net gridview updatepanel postback


    【解决方案1】:

    使用UpdatePanel 的部分呈现不会改变或影响 ASP.NET 中的整个页面生命周期。

    这是一个小技巧,用于仅在浏览器中重新渲染页面的某个区域(UpdatePanel),但没有其他任何变化,所以是的,看到 Page_Load 和所有其他事件照常触发是正常的;它必须是那样的,否则它不会工作:)

    【讨论】:

      【解决方案2】:

      是的,在更新面板更新期间,每次异步回发到服务器时都会调用 page_load,为了克服这个问题,您可以使用 jquery ajax。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-08-21
        • 1970-01-01
        • 2011-06-14
        • 2017-07-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多