I'm trying to use a Master Page in my Web App and not having much luck. Can someone point me to a straight and simple page that explains how to use them please?
Thanks,
Printable View
I'm trying to use a Master Page in my Web App and not having much luck. Can someone point me to a straight and simple page that explains how to use them please?
Thanks,
Create a Master Page. Put a Content area on it (since 2010 I think it defaults to a Header Content and a Content1, maybe 2012).
Create a new Web Page, it will have an option to select master page, click that check box, set your master page you just create as the master page, save. New page will be created with content tags to match whatever was on the master page, put your markup inside those.
In it's simplest form, usually use the Master Page for Menu area and a footer, on the other page put things like scripts in the Header content area and controls in the Content1 area.
Which version of Visual Studio are you using? In 2010 (not sure if it is in earlier versions) you can create a Master Page how you want, and then you can add a new item to your project with the type of "Web Form using Master Page."
It should then show you how to create your own page based on a Master Page.
blakemckenna, one of the nice things about the last 10 years of the internet is there seems to be tons of tutorials, for just about everything, especially when it comes to Microsoft products and technologies. The first result when I searched for "asp.net master page tutorial" lead me to this: http://www.asp.net/web-forms/tutorials/master-pages
There's a few hundred thousand more if you dont like that one.
I'm actually using VS 2008. Thanks for the tips guys!
2008 I think you have to drop your own Content sections on the Master Page. But it still should be as easy as creating a new page then and somewhere on the lower right is gives you an option to use a master page with it, click that option, select your master page, and then put you controls inside the content tags on the new page.
Thanks Sean...
In VS 2005, 2008, & 2010 when you add a MasterPage to the project, it gives you the ContentPlacerHolder in the head and one in the body by default. When you add a WebContentForm to the project, select the MasterPage, it by default adds as many PlaceHolders as the master page has, in the order they are in the MasterPage file. You never need to add your own, unless you delete one first and need to re-add it.
That being said, it's possible to have multiple ContentPlaceHolder's in the body section of the MasterPage, typically you wont, but you can if you layout your page that way.
Yes we are sure.
P.S. I used multiple contentplaceholder in a web site that needed 3 vertical sections independent from each other. I asked about that a year ago here and on the asp forum and i think is a legit way to construct your master page. So i wouldn't say it's that rare to use multiple placeholders.
I think Blake was asking for a recommendation of the thousands that are out there. That's one of my problems, too. There's so much, you don't know what's crap (even if it works it could be crap) and what's a best practice. That's why I usually turn to the experts here to find out how they've crafted their apps.