473,666 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do you prefer Master Page or User Controls?

I know that sometimes referring to controls deep in a page using a Master
Page can be funky.

For a website using a standard header/footer/nav, do you prefer using User
Controls for the common items, or do you prefer Master Pages?

What is best from your experience? I've downloaded a few sample projects
(like for the Telerik Rad Controls) and have noticed that they like to use
User Controls.

What are the pros/cons of each?

Thanks.
Jun 27 '08 #1
10 3583
I am using user controls for the header and the footer. Master pages, with
all their convenience, certainly do introduce an extra level of complexity.
There are many issues and considerations related to them. I use them for
specific purposes when I anticipate that they can cover significant
functionality. Header and footer are often general for all pages and don't
usually include any reach functionality.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Cirene" <ci****@nowhere .comwrote in message
news:ew******** ******@TK2MSFTN GP03.phx.gbl...
>I know that sometimes referring to controls deep in a page using a Master
Page can be funky.

For a website using a standard header/footer/nav, do you prefer using User
Controls for the common items, or do you prefer Master Pages?

What is best from your experience? I've downloaded a few sample projects
(like for the Telerik Rad Controls) and have noticed that they like to use
User Controls.

What are the pros/cons of each?

Thanks.

Jun 27 '08 #2
"Cirene" <ci****@nowhere .comwrote in message
news:ew******** ******@TK2MSFTN GP03.phx.gbl...
>I know that sometimes referring to controls deep in a page using a Master
Page can be funky.

For a website using a standard header/footer/nav, do you prefer using User
Controls for the common items, or do you prefer Master Pages?

What is best from your experience? I've downloaded a few sample projects
(like for the Telerik Rad Controls) and have noticed that they like to use
User Controls.

What are the pros/cons of each?
In addition to Eliyahu's response, MasterPages are actually UserControls
anyway... There is often a misconception (not aimed at you) that MasterPages
are somehow the ASP.NET implementation of framesets - nothing could be
further from the truth...

Eliyahu is also correct in that MasterPages do introduce a certain level of
complexity, but it's not exactly rocket science... :-)

IMO, MasterPages were one of the major innovations in ASP.NET 2, and I
personally never use anything else for common layout.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #3
jc
On 20 mayo, 06:22, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
"Cirene" <cir...@nowhere .comwrote in message

news:ew******** ******@TK2MSFTN GP03.phx.gbl...
I know that sometimes referring to controls deep in a page using a Master
Page can be funky.
For a website using a standard header/footer/nav, do you prefer using User
Controls for the common items, or do you prefer Master Pages?
What is best from your experience? *I've downloaded a few sample projects
(like for the Telerik Rad Controls) and have noticed that they like to use
User Controls.
What are the pros/cons of each?

In addition to Eliyahu's response, MasterPages are actually UserControls
anyway... There is often a misconception (not aimed at you) that MasterPages
are somehow the ASP.NET implementation of framesets - nothing could be
further from the truth...

Eliyahu is also correct in that MasterPages do introduce a certain level of
complexity, but it's not exactly rocket science... :-)

IMO, MasterPages were one of the major innovations in ASP.NET 2, and I
personally never use anything else for common layout.
IMHO

Master pages are not really user control. It's really hard to debug on
user control but master page.

Jun 27 '08 #4
I hate to disagree with you, but Mark is right - according to Microsoft,
Masterpages become implementations of User controls on the pages

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"jc" <jc*********@ya hoo.eswrote in message
news:b0******** *************** ***********@t54 g2000hsg.google groups.com...
On 20 mayo, 06:22, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
"Cirene" <cir...@nowhere .comwrote in message

news:ew******** ******@TK2MSFTN GP03.phx.gbl...
<snip>
In addition to Eliyahu's response, MasterPages are actually UserControls
anyway...
<snip>
IMO, MasterPages were one of the major innovations in ASP.NET 2, and I
personally never use anything else for common layout.
IMHO

Master pages are not really user control. It's really hard to debug on
user control but master page.
Jun 27 '08 #5
I agree with David.

MasterPage class is derived from System.Web.UI.U serControl as opposed to
System.Web.UI.P age.

--
Madhur
http://blogs.msdn.com/mahuja

"David Wier" <dw@dw.comwro te in message
news:eu******** ******@TK2MSFTN GP03.phx.gbl...
>I hate to disagree with you, but Mark is right - according to Microsoft,
Masterpages become implementations of User controls on the pages

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
no bloated markup
"jc" <jc*********@ya hoo.eswrote in message
news:b0******** *************** ***********@t54 g2000hsg.google groups.com...
On 20 mayo, 06:22, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
>"Cirene" <cir...@nowhere .comwrote in message

news:ew******* *******@TK2MSFT NGP03.phx.gbl.. .
<snip>
>In addition to Eliyahu's response, MasterPages are actually UserControls
anyway...
<snip>
>IMO, MasterPages were one of the major innovations in ASP.NET 2, and I
personally never use anything else for common layout.

IMHO

Master pages are not really user control. It's really hard to debug on
user control but master page.

Jun 27 '08 #6
"jc" <jc*********@ya hoo.eswrote in message
news:b0******** *************** ***********@t54 g2000hsg.google groups.com...
IMHO

MasterPages are not really UserControl.
That's incorrect. A MasterPage most certainly is a UserControl. In fact, all
MasterPages by default inherit from the UserControl class:

http://msdn.microsoft.com/en-us/libr...asterpage.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #7
Yes and no.

Technically, yes, master pages are user controls. But from development
pattern perspective they are very different. Typically, regular user
controls address one well-defined and limited task whereas master pages are
commonly used as a base for building the whole page with much richer markup
and code-behind. Perhaps that's why many developers don't perceive master
pages as user controls.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:Op******** *****@TK2MSFTNG P06.phx.gbl...
"jc" <jc*********@ya hoo.eswrote in message
news:b0******** *************** ***********@t54 g2000hsg.google groups.com...
>IMHO

MasterPages are not really UserControl.

That's incorrect. A MasterPage most certainly is a UserControl. In fact,
all MasterPages by default inherit from the UserControl class:

http://msdn.microsoft.com/en-us/libr...asterpage.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #8
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>>IMHO

MasterPages are not really UserControl.

That's incorrect. A MasterPage most certainly is a UserControl. In fact,
all MasterPages by default inherit from the UserControl class:

http://msdn.microsoft.com/en-us/libr...asterpage.aspx

Technically, yes, master pages are user controls.
There's no need to go any further... :-)
Perhaps that's why many developers don't perceive master pages as user
controls.
Nevertheless that's what they are, regardless of how many developers
perceive them....

Lots of developers, especially beginners, perceive MasterPages as
framesets - that doesn't mean they're framesets.

In fact, it's been my experience that once developers realise that
MasterPages are precisely UserControls, then their understanding of what
they are and how to use them increases dramatically...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #9
re:
!MasterPage class is derived from System.Web.UI.U serControl as opposed to System.Web.UI.P age.

The UserControl, Page and MasterPage classes all are subclasses of System.Web.UI.

See :
http://quickstarts.asp.net/QuickStar...=System.Web.UI

When an HTTP request is made for a page at run time, the master page and content
pages are combined into a single class with the same name as the content pages.

The *resulting* compiled, merged class derives from the Page class.

The MasterPage class derives (inherits, actually) from Control,
and is last in a chain which includes Control, TemplateControl and UserControl:

Here's the inheritance hierarchy for the MasterPage class :

System..::.Obje ct
System.Web.UI.. ::.Control
System.Web.UI.. ::.TemplateCont rol
System.Web.UI.. ::.UserControl
System.Web.UI.. ::.MasterPage

The master page is initialized as the top control in a page’s control hierarchy by
clearing the page’s Controls array and adding the master page to the Control collection.

The master page initialization happens after the PreInit event
fires for a Page object, but before the Init event fires.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"Madhur" <sd*@df.comwrot e in message news:95******** *************** ***********@mic rosoft.com...
>I agree with David.

MasterPage class is derived from System.Web.UI.U serControl as opposed to System.Web.UI.P age.

--
Madhur
http://blogs.msdn.com/mahuja

"David Wier" <dw@dw.comwro te in message news:eu******** ******@TK2MSFTN GP03.phx.gbl...
>>I hate to disagree with you, but Mark is right - according to Microsoft, Masterpages become implementations of User
controls on the pages

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no bloated markup
"jc" <jc*********@ya hoo.eswrote in message
news:b0******* *************** ************@t5 4g2000hsg.googl egroups.com...
On 20 mayo, 06:22, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
>>"Cirene" <cir...@nowhere .comwrote in message

news:ew****** ********@TK2MSF TNGP03.phx.gbl. ..
<snip>
>>In addition to Eliyahu's response, MasterPages are actually UserControls
anyway...
<snip>
>>IMO, MasterPages were one of the major innovations in ASP.NET 2, and I
personally never use anything else for common layout.

IMHO

Master pages are not really user control. It's really hard to debug on
user control but master page.


Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2417
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the web part page? Does it take place at the page level? ...or the content area level? 3. Where is the Web Part Manager instantiated? ...in the Master Page? ....Content Page? ...elsewhere?
20
2417
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the include files to change the layout. When I came to ASP.NET, I used user controls to do a similar thing. I have just been looking at master pages, and it looks like they do the same thing. If so, is there any advantage in using them over the...
2
3078
by: Scott | last post by:
I'm using a master page (mp_TableMaint.aspx) with one Content area (ID: Content1). Content1 contains several usercontrols, which are hidden. The goal is to show the correct control based on the querystring passed when calling mp_TableMaint (the page is called from an ASP.NET 2.0 Menu control on my index.aspx page). I believe I understand correctly that the Master Page's ASP Content control (named Content1) is, itself, a server side...
1
3269
by: Dabbler | last post by:
I have some hyperlink controls on a master page I need to disable till my user has made some selections in a user control on a page based on the master page. How do I reference the Hyperlink controls in the master page? How can I get the Master Page to re-render itself after I've done this? Thanks for any suggestions on this. Dabbler
2
1390
by: Chris Davoli | last post by:
I initially created a master page for a common look and feel in my project. I am trying to refer to a user control that is on a master page. When I add a new web form to the project I check the checkbox for "Select master page" so the page has the same look and feel as the master page. The problem comes in when I want to refer to the user controls on the master page when I'm in the web form. I can't seem to figure out how to do this. Does...
1
1243
by: | last post by:
Hey all! I'm new to 2.0. I use user controls, and since 99% of browsers have css now, I use absolute positioning to place my user controls.(Top banners, menus on the left side etc). In my case, what is the advantage of Master/Content? I could see it if I used tables for my pages... Don't user controls do most of what Master/Content does? Tks Justin Dutoit
0
2810
by: Daniel Magliola | last post by:
I'm having a weird behaviour when implementing localization resource files in my website. This looks like a .Net bug to me, but it's too obvious to be there, so I must be overlooking something. I have the following file structure: + root folder |-----Masterpage.master |-----Somepage.aspx
0
2187
by: robgallen | last post by:
I have 2 user controls within a master page, and I would like one of them to call a function in the other. All the examples I have seen involve a page communicating with the Master page, or with a user control communicating with the Master page, not with a user control directly talking to another user control, bypassing the page itself. So, I have the following files: Haep.master - which contains:
3
1439
by: Cirene | last post by:
When you set the value of a user control in a master page, do you have to reference it differently? Also, do they have to be given different names in the templates? For example, this is what I have.... (uc1 is a user control I defined) MasterPage.master -- FormView#FormView1 --<EditItemTemplate>
0
8448
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.