MasterPage vs User Control

Last post 08-27-2008 1:59 PM by bdunn13. 7 replies.

Sort Posts:

  • MasterPage vs User Control

    08-21-2008, 11:40 AM
    • Member
      46 point Member
    • newbieAl
    • Member since 10-18-2007, 11:43 PM
    • Posts 303

    I've a 2.0 .NET web app that I created in VS2003.  Every page has same info, such as header and footer.  At first I created a MasterPage.  MasterPage just included header and footer, however I came across another solution that shows the use of User Control (create footer.ascx and header.ascx) for this purpose and not MasterPage.

    I'm confused as to which solution I should implement.  Which is the better one and why?

  • Re: MasterPage vs User Control

    08-21-2008, 11:45 AM
    • Participant
      1,077 point Participant
    • G0ggy
    • Member since 05-22-2007, 1:58 PM
    • Posts 297

     I think the ASCX extension and 'includes' goes back to the days of classic ASP. You should use master pages.



    Remember to mark as answer the solution which helped you.
  • Re: MasterPage vs User Control

    08-21-2008, 1:03 PM
    Answer
    • Member
      370 point Member
    • WisamAL
    • Member since 08-21-2008, 4:19 PM
    • Jerusalem
    • Posts 57

    I prefer master page
    Advantages of Master Pages

    Master pages provide functionality that developers have traditionally created by copying existing code, text, and control elements repeatedly; using framesets; using include files for common elements; using ASP.NET user controls; and so on. Advantages of master pages include the following:

    • They allow you to centralize the common functionality of your pages so that you can make updates in just one place.

    • They make it easy to create one set of controls and code and apply the results to a set of pages. For example, you can use controls on the master page to create a menu that applies to all pages.

    • They give you fine-grained control over the layout of the final page by allowing you to control how the placeholder controls are rendered.

    • They provide an object model that allows you to customize the master page from individual content pages.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: MasterPage vs User Control

    08-21-2008, 1:58 PM
    Answer
    • Member
      365 point Member
    • bdunn13
    • Member since 01-30-2006, 2:56 PM
    • Georgia
    • Posts 86

     I would use both. I mainly use masterpages for doing layout changes. I use usercontrols for creating specific content. For example, I would create user controls for login, header, footer, weather item, stock ticker, news ticker.

     

    Then you could easily use those same controls in a different master page with a different look and feel without duplicating any code.

     

    BD

  • Re: MasterPage vs User Control

    08-21-2008, 2:07 PM
    • Member
      178 point Member
    • Hovgaard
    • Member since 09-08-2006, 3:57 PM
    • Denmark
    • Posts 49

    All true..

    If you do need to have the option to split the header and footer, use user controls. If you wanna include both the header and footer, use the MasterPage.

    Personally I hate the idea of going back to the classic ASP method. Use the MasterPage, you will love it :)

  • Re: MasterPage vs User Control

    08-27-2008, 11:58 AM
    • Member
      46 point Member
    • newbieAl
    • Member since 10-18-2007, 11:43 PM
    • Posts 303

     I agree.  I'm loving this solution.  It works well for my app and appreciate that I only have to make changes in one place!

  • Re: MasterPage vs User Control

    08-27-2008, 12:02 PM
    • Member
      251 point Member
    • Emyr
    • Member since 07-25-2008, 9:51 AM
    • Wales
    • Posts 82

     I use Master Pages and User Controls: My site requires a variety of layouts, so I have a user control for each component of the layout, then I use the master pages to combine these components in different ways.

    In fact, I can't think of any reason not to use both! Big Smile



    originalPoster = forumthread.GetOP;
    answerPost = originalPoster.Answerfound(forumthread);
    (answerPost!=null?answerPost.markAsAnswer():originalPoster.GiveMoreInfo(forumthread));
  • Re: MasterPage vs User Control

    08-27-2008, 1:59 PM
    • Member
      365 point Member
    • bdunn13
    • Member since 01-30-2006, 2:56 PM
    • Georgia
    • Posts 86
    Agreed.
Page 1 of 1 (8 items)