母版页和回发在ASP.NET [英] Master Pages and Postback in ASP.NET

查看:153
本文介绍了母版页和回发在ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何避免母版页可以发布回整个页面?

How can we avoid Master Page from posting back the whole page?

推荐答案

只是为了澄清 - 更新面板并不prevent一整页回发或一整页的生命周期。它只是使这一进程在后台看不见的用户可以完成。唯一的区别是,回发完成时仅部分包裹更新面板声明被刷新,因此引起该网页的仅一部分被回发的错觉。

Just to clarify - the update panel doesn't prevent a whole page postback or a full page lifecycle. It just causes that process to be completed in the background "unseen" to the user. The only difference is that upon completion of the postback only the section wrapped by the update panel declaration is refreshed, thus causing the illusion that only part of the page is posted back.

如果触发控制在UpdatePanel里面,那么你应该设置ChildrenAsTriggers属性等于True。如果触发更新控制更新面板之外,那么你就应该添加触发器部分控制面板,并添加一个异步触发。如果它是一个组合,那么你可以将二者结合起来的最佳效果。

If the trigger control is inside the updatepanel then you should set the ChildrenAsTriggers attribute equal to True. If the control that triggers the update is outside the update panel, then you should add the Triggers section to the control panel and add an asynchronous trigger. If it is a combination, then you could combine the two for the best effect.

如果触发更新的控件包含更新面板里面:

If the control that triggers the update is contained inside the update panel:

<asp:UpdatePanel id="MyUpdatePanel" runat="server" ChildrenAsTriggers="True">
  <ContentTemplate>
    ...Stuff you want updated
  </ContentTemplate>
</asp:UpdatePanel>

或者,如果控制不包含更新面板里面:

Or if the control isn't contained inside the update panel:

<asp:UpdatePanel id="MyUpdatePanel" runat="server">
  <ContentTemplate>
    ...Stuff you want updated
  </ContentTemplate>
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="MyButtonControl" EventName="Click" />
  </Triggers>
</asp:UpdatePanel>

这篇关于母版页和回发在ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆