Master Pages and Postbacks in ASP.NET

How can we avoid the homepage after publishing the entire page?

0


source to share


3 answers


Just to clarify - the refresh panel does not prevent an entire page from returning or the life cycle of a full page. This simply causes the process to end in the background "invisible" to the user. The only difference is that after the postback completes, only the section wrapped by the update bar declaration is updated, which gives the illusion that only part of the page will be sent back.

If the trigger control is inside the update pane, you must set the ChildrenAsTriggers attribute to True. If the control that triggers the update is outside of the update panel, then you must add the Triggers section to the control panel and add an asynchronous trigger. If it's a combination, you can combine the two for a better 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 is not contained inside the update bar:

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

      

+2


source


Using the homepage doesn't really affect whether the entire page is returned or not. A simple ASPX page without wizard and standard number will also do the entire page back of the page.

Reading between the lines, however, I am assuming that your master page already has several UpdatePanels (possibly surrounding content placeholders) that prevent the entire page from being refreshed when something inside them triggers a postback.



In any case, the key to preventing a full page from being refreshed (whether using master pages or not) is that the control that triggers the feedback lives inside the UpdatePanel, or uses some JavaScript to call back to the server and process the response asynchronously.

+1


source


The master page is not responsible for PostBack, which is what the HTML form is for.

The only way to prevent the page from being published is to wrap the whole thing in an UpdatePanel. But this is a really bad idea itself!

0


source







All Articles