1

I'm working on an ASP.NET website, which I'm building in Visual Studio.

I want to reuse the header and footer on all pages without copying the HTML to all of them.

I have looked through the below answers, but they're both written for PHP. Can someone please help show how to do this in ASP.NET?

How to display same header and footer on different pages?

Keeping my header and footer on all webpages?

Community
  • 1
  • 1

1 Answers1

1

You should use ASP.NET Master Pages for this purpose:

ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.

Master Pages allow you to centralize the common functionality of your pages so that you can make updates in just one place.

Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
  • @mason Thanks guys for answering, Im working on WebForms but not all the pages are perticularly webForms, some are simple Web pages and i have an idea about master page, but will it be the best choice compared to using 'include' or 'user control'? – Taquer outlaw.shade Oct 25 '15 at 14:55
  • @Taqueroutlaw.shade Why not just convert all your simple HTML pages over to Web Forms .aspx? That way you can take advantage of some of the Web Forms features like Master Pages and virtual URL path resolution. – mason Oct 25 '15 at 14:57
  • @mason i guess that's be the best way to do it. thanks – Taquer outlaw.shade Oct 25 '15 at 15:01