简体   繁体   English

在单击UpdatePanel内的GridView页面时,Page_Load是否正常触发?

[英]Is it normal for Page_Load to trigger upon clicking a page of a GridView inside an UpdatePanel?

I have this code in my aspx page: 我在我的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>

By pressing on another page of the GridView the Page_Load is triggered, is this normal behavior for a partial postback? 通过按GridView的另一个页面触发Page_Load,这是部分回发的正常行为吗?

Partial rendering using UpdatePanel does not change or affect the whole Page life cycle in ASP.NET. 使用UpdatePanel部分呈现不会更改或影响ASP.NET中的整个页面生命周期。

it's a small trick used to re-render only a certain region of the page in the browser (the UpdatePanel) but nothing else change, so yes, it's normal to see Page_Load and all other events to be triggered as usual; 它是一个小技巧,用于在浏览器中重新呈现页面的某个区域(UpdatePanel)但没有其他任何改变,所以是的,看到Page_Load和所有其他事件照常被触发是正常的; it has to be like that or it would not work :) 它必须是那样或它不会工作:)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM