|
-
Apr 25th, 2013, 11:58 AM
#1
Thread Starter
PowerPoster
Using MasterPages???
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,
-
Apr 25th, 2013, 12:10 PM
#2
Frenzied Member
Re: Using MasterPages???
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.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Apr 25th, 2013, 12:47 PM
#3
Re: Using MasterPages???
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.
-
Apr 25th, 2013, 12:57 PM
#4
Re: Using MasterPages???
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.
-
Apr 25th, 2013, 01:39 PM
#5
Thread Starter
PowerPoster
Re: Using MasterPages???
I'm actually using VS 2008. Thanks for the tips guys!
-
Apr 25th, 2013, 01:48 PM
#6
Frenzied Member
Re: Using MasterPages???
 Originally Posted by blakemckenna
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.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Apr 25th, 2013, 03:09 PM
#7
Thread Starter
PowerPoster
-
Apr 25th, 2013, 09:14 PM
#8
Re: Using MasterPages???
 Originally Posted by SeanGrebey
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.
If by that you mean ContentPlaceHolder then no you don't need to. At least the basic functionality is there but of course you can expand it.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Apr 26th, 2013, 08:32 AM
#9
Re: Using MasterPages???
 Originally Posted by SeanGrebey
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.
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.
-
Apr 26th, 2013, 01:21 PM
#10
Frenzied Member
Re: Using MasterPages???
 Originally Posted by JuggaloBrotha
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.
You sure on that? Granted it is been a while but I thought having a head content section didn't come until later versions.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Apr 26th, 2013, 05:53 PM
#11
Re: Using MasterPages???
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Apr 26th, 2013, 08:36 PM
#12
Re: Using MasterPages???
 Originally Posted by SeanGrebey
You sure on that? Granted it is been a while but I thought having a head content section didn't come until later versions.
Yes-sir, been using them since VS2005, I have ot admit I did open VS2008 and created a new asp.net project to confirm right before posting.
-
May 1st, 2013, 01:18 PM
#13
Re: Using MasterPages???
 Originally Posted by JuggaloBrotha
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 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.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|