tags:

views:

23

answers:

2
+3  Q: 

master page menus

Hi I want to create a master page for my already developed project.Since the project contains many forms it is quite difficult to include the master page in each form...Is there any possibilities to include the master page in any other simplest way...

Please give some suggestions..

Thanks in advance...

+1  A: 

As far as I know, there is no easy way to do this.

You'll have to manually add the masterpage to the page directive

<%@ Page MasterPageFile="~/Masterpage.master" ... %>

add the relevant content sections around your pages markup:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>

and remove the <html>, <head>, <body> and <form> tags from every page.


Update

Here is an article (and source code) by Bob Powell describing a way to automatically convert html files to aspx files and add a master page. I'm sure you could adapt it to your needs.

geoff
A: 

This transition is not an easy one to make, as @geoff indicates. It is possible though if you have enough time and patience. The first step is to take all common elements (layout, menu, header, footer, whatever is common) and develop a master page structure. You'll likely need more than 1 depending on the differing layouts of forms in your application. Develop a user control for each of these common sections and make sure the master pages use these controls. Then systematically go through each page of your site and begin implementing the master pages.

As an assistance mechanism, you'll also probably want to have a page baseclass that is capable of communicating through the master page to the contained user controls. In our group we have a standard for setting a property on UserControls and MasterPages called ParentForm that is of type of our primary base page class, and this property is set during the Init of any page or control so that at any time, the developer has access (through Intellisense) to page itself. This is especially helpful since the parent of most controls is a container whose parent is a container whose parent ... you get the idea. For our controls it's just this.ParentForm.

It will be a long process, but MasterPages were really intended to be a "ground up" architectural decision rather than an "employ later" concept.

Joel Etherton