tags:

views:

579

answers:

5

Classic ASP had 'server side includes' so that one could easily design a generic layout for the header, footer, left or right side bar.

In ASP.Net, I think we must use 'Page Templates'. Although most people say that it is easy to use, I find it rather complicated, as we must copy the whole HTML code inside the 'Render' function. Is there a simpler method? Can I load the code from a HTML file instead pasting the whole code in the 'Render' function?

Or is there any better alternative to 'Page Templates'?

+1  A: 

ASP.Net 2.0+ utilize Master Pages.

SaaS Developer
+10  A: 

I would have thought Master Pages were the standard approach in ASP.NET (2.0 and later).

  1. Design the master page in the designer.
  2. Designate the content area or areas within this master page.
  3. Then simply design separate "content" pages and indicate the original master page in the Page directive.

Note this is all visually created, no need to manually copy html in Init/Load/Render events, ASP.NET does it for you.

A good book I've read is Essential ASP.NET 2.0 by Frtiz Onion. It has a good succinct discussion of master pages in Chapter 2.

Ash
Fritz is 'dah man', I have both editions of Essential ASP.NET, both ace texts.
Kev
A: 

Master Pages and User Controls combine to give you way more power than ASP includes did.

John Sheehan
A: 

I agree with Ash and John. Design a .master page to hold all the content that you want to be visible on all pages. From my experience, Headers, footers side go into the master page. Then Add <asp:content id='page_contents'> tag to hold the page content that changes in every page.

If you have authentication page, where you allow a user to login, I would suggest not to include the master file for the form.

Rajeshwaran S P
A: 

MasterPages are the right thing to do here. Passing information back and forth from content to master can be difficult. I recommend this article from Scott Mitchell regarding this topic as it will save you some headache.

David Robbins