Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use UpdatePanel in MasterPage to wrap nested pages?

Can I use Update panel in masterpage to wrap nested pages so that when browsing from one page to the other client only gets a partial refresh (MasterPage doesn't get reloaded).

If so - how? Do I Just put an update panel around the ContentPlaceholder in the Master Page?

Any help appreciated!

like image 348
JohnIdol Avatar asked Dec 13 '08 12:12

JohnIdol


People also ask

What is the use of UpdatePanel?

UpdatePanel controls are a central part of AJAX functionality in ASP.NET. They are used with the ScriptManager control to enable partial-page rendering. Partial-page rendering reduces the need for synchronous postbacks and complete page updates when only part of the page has to be updated.

Can we use multiple UpdatePanel in asp net?

By using multiple UpdatePanel controls on a page, you can incrementally update regions of the page separately or together. For more information about partial-page updates, see Partial-Page Rendering Overview and Introduction to the UpdatePanel Control.

What happens when a button placed in the UpdatePanel control is clicked?

The UpdatePanel control contains a Button control that refreshes the content inside the panel when you click it.

How Master pages can be nested?

Master pages can be nested, with one master page referencing another as its master. Nested master pages allow you to create componentized master pages. For example, a large site might contain an overall master page that defines the look of the site.


1 Answers

I do not advise you to wrap an entire page in an UpdatePanel, for the following reasons:

  • If you want your site to be index by Search Engines, you will need to display your content on separate pages...just having a different querystring on each content section is enough. This is because for search engines Content Is King and since search engines currently cannot index dynamically generated data, they will not be able to index your pages.

  • Wrapping entire pages in an Update Panel is very dangerous because of the huge overhead that is sent to the server. You will see a significant performance decrease if you do so. Read this article for more information on the subject

  • Because of this huge overhead, it is suggested to use the Update Panel to update just small sections of the website (like little box widgets on the side, etc...) and not whole content sections.

  • Wrapping content sections in an update panel means that you will have to go the extra mile dynamically changing the url (using # anchors) manually yourself, and this is so that you will give users the ability to use the back button on their browser to go to the previous section of the site. Not having the ability to go back in a page is very annoying for users


Here is an example that demonstrates the problem with UpdatePanels.

The following is code for a simple aspx page with a label and a button :

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" ID="up1">
 <ContentTemplate>
   <asp:Label runat="server" ID="Label1" Text="Update Me!" /><br />
   <asp:Button runat="server" ID="Button1" 
     Text="Postback Update" OnClick="Button1_Click" />
 </ContentTemplate>
</asp:UpdatePanel>

 

protected void Button1_Click(object sender, EventArgs e)
{
  Label1.Text = DateTime.Now.ToLongDateString();
}

And the following is a partial postback done with the UpdatePanel when the button is clicked (notice the huge overhead involved) :

                  alt text
(source: encosia.com)

As you can see, the server is basically sending all the elements that are in the UpdatePanel back to the client.


On the other hand, here is an example that involves using ASP.Net Page Methods. Notice the response sent from the server this time (no UpdatePanels involved) :

                    alt text
(source: encosia.com)

like image 189
Andreas Grech Avatar answered Sep 23 '22 21:09

Andreas Grech