Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Persisting MasterPage content in client browser between PostBacks

Status
Not open for further replies.

blondebier

Programmer
Jun 19, 2003
142
GB
Hi Guys,

As the title says, I'm looking for some way of making content from my MasterPage remain static and only change the content when the page is posted back to the server.

I have a header and a footer on my master page that remains completely static. Is it possible to keep these on the client and only have content post back. I.e. I have navigation and content that would change.

The only reason being that sometimes post backs can take a few seconds(5s) to complete and it would make my application better if the header and footer remained in the browser throughout.

Any ideas?

Cheers,

Francis
 
Yes, by using an AJAX approach. Microsoft's implementation of this can be found at and will involve placing an UpdatePanel around your ContentPlaceholder.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Thanks for the reply. I have been delving into AJAX and so far I am quite impressed.

Going back to my scenario detailed in my original post I wandered if you could just clear something up... as there don't seem to be any examples like this available.

Currently I have a MasterPage with 4 ContentPlaceHolders on it. Header (top), Footer (bottom), Navigation (middle left), WebContent (middle right).

I then have WebContentForms that only have 1 ContentPlaceHolder in the html i.e. WebContent and then code behind to do whatever is needed.

If I use the AJAX approach in this framework where would the UpdatePanel go? In my MasterPage or WebContentForm?

If my navigation throws an event that would normally response.redirect to another WebContentForm, would I get the ScriptManager on my MasterPage to catch this event and only refresh the UpdatePanel on my MasterPage?

Is it possible to fill an UpdatePanel with the contents of a WebContentForm to replace the response.redirect to the WebContentForm?

I'm new to AJAX so any tips would be greatly appreciated.

Ideally, i'd just like to make changes to my MasterPage as my whole application contains in excess of 100 WebContentForms.

Cheers for any advice.
 
My other thoughts are could you bind an UpdatePanel to WebContentForm? Like using Databind with other controls?
 
you could place your header and footer into an UserControl and cache them then reference your header/footer on the master page.
example
header
Code:
<%@ Control ...%>
<%@ OutputCache Duration="1000" Shared="true" VarByParam="none" %>
<p>Header</p>
footer
Code:
<%@ Control ...%>
<%@ OutputCache Duration="1000" Shared="true" VarByParam="none" %>
<p>Footer</p>
master
Code:
<%@ Master ...%>
<%@ Register src="header.ascx" TagName="Header" TagPrefix="uc" %>
<%@ Register src="footer.ascx" TagName="Footer" TagPrefix="uc" %>
<html>
   ...
   <body>
      <form>
         <uc:Header id="myHeader" runat="server" />
         <asp:ContentPlaceHolder id="myPlaceHolder" runat="server" />
         <uc:Footer id="myFooter" runat="server" />
      </form>
   </body>
</html>

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks for the reply.

Aren't they still going to disappear when each page posts back though?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top