Results 1 to 13 of 13

Thread: Using MasterPages???

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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,
    Blake

  2. #2
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    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.

  3. #3
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    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.

  4. #4
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    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.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using MasterPages???

    I'm actually using VS 2008. Thanks for the tips guys!
    Blake

  6. #6
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Using MasterPages???

    Quote Originally Posted by blakemckenna View Post
    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.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using MasterPages???

    Thanks Sean...
    Blake

  8. #8
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Using MasterPages???

    Quote Originally Posted by SeanGrebey View Post
    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.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  9. #9
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Using MasterPages???

    Quote Originally Posted by SeanGrebey View Post
    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.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  10. #10
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Using MasterPages???

    Quote Originally Posted by JuggaloBrotha View Post
    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.

  11. #11
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    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.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  12. #12
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Using MasterPages???

    Quote Originally Posted by SeanGrebey View Post
    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.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  13. #13
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: Using MasterPages???

    Quote Originally Posted by JuggaloBrotha View Post
    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
  •  



Click Here to Expand Forum to Full Width