aspx to master page

J

John

Hi

Is there a way to convert a pre-designed aspx page to a master page? I have
tried to save the page as master using the Save As feature but it still
saves as aspx.

Any ideas?

Thanks

Regards
 
N

Nathan Sokalski

The only real differences are the following:


Change the @Page directive to an @master directive (and, if necessary, any
attributes of the directive)

Add any ContentPlaceHolder controls that you want in the Master Page

In the codebehind, change it so that it inherits from
System.Web.UI.MasterPage instead of System.Web.UI.Page


My recommendation would be to just add a new Master Page and copy & paste
any code you want from the old regular Page, and then make any necessary
modifications. There is no built-in way to do this, because of the way
Master pages are intended to be used (they should only contain content that
is on multiple pages, so one page is not going to be enough for any tool to
determine what belongs in a Master Page). If you have a project that was
designed without using Master Pages that you want to find the similarities
between the pages, a file comparison tool that might be helpful is:

http://www.sourcegear.com/diffmerge/downloads.html

Hopefully all this helps, but as a suggestion for the future, it is best to
create the Master Page before creating any of the actual pages. This way
Visual Studio can let you select which one of your Master Pages you want to
use and automatically put the Content controls in the Page for you when you
create it. Good Luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top