473,245 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 software developers and data experts.

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 3546
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**************@TK2MSFTNGP03.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**************@TK2MSFTNGP03.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...@markNOSPAMrae.netwrote:
"Cirene" <cir...@nowhere.comwrote in message

news:ew**************@TK2MSFTNGP03.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*********@yahoo.eswrote in message
news:b0**********************************@t54g2000 hsg.googlegroups.com...
On 20 mayo, 06:22, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"Cirene" <cir...@nowhere.comwrote in message

news:ew**************@TK2MSFTNGP03.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.UserControl as opposed to
System.Web.UI.Page.

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

"David Wier" <dw@dw.comwrote in message
news:eu**************@TK2MSFTNGP03.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*********@yahoo.eswrote in message
news:b0**********************************@t54g2000 hsg.googlegroups.com...
On 20 mayo, 06:22, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>"Cirene" <cir...@nowhere.comwrote in message

news:ew**************@TK2MSFTNGP03.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*********@yahoo.eswrote in message
news:b0**********************************@t54g2000 hsg.googlegroups.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**@markNOSPAMrae.netwrote in message
news:Op*************@TK2MSFTNGP06.phx.gbl...
"jc" <jc*********@yahoo.eswrote in message
news:b0**********************************@t54g2000 hsg.googlegroups.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.orgwrote in
message news:%2****************@TK2MSFTNGP05.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.UserControl as opposed to System.Web.UI.Page.

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..::.Object
System.Web.UI..::.Control
System.Web.UI..::.TemplateControl
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.comwrote in message news:95**********************************@microsof t.com...
>I agree with David.

MasterPage class is derived from System.Web.UI.UserControl as opposed to System.Web.UI.Page.

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

"David Wier" <dw@dw.comwrote in message news:eu**************@TK2MSFTNGP03.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*********@yahoo.eswrote in message
news:b0**********************************@t54g200 0hsg.googlegroups.com...
On 20 mayo, 06:22, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>>"Cirene" <cir...@nowhere.comwrote in message

news:ew**************@TK2MSFTNGP03.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
I see a bunch of off-topic discussion about whether MasterPages are
userControls (they are). I use MasterPages quite frequently as they make it
very easy to "skin" a page with a consistent layout, theme and features.
They do introduce an additional level of complexity from a programmatic
perspective but as others have indicated, once you understand what a
MasterPage actually is, it's not rocket science.

Usercontrols fit in more as specific units of functionality to be dropped on
to the page proper. Hope that helps.
Peter
"Cirene" <ci****@nowhere.comwrote in message
news:ew**************@TK2MSFTNGP03.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 #11

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

Similar topics

5
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...
20
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...
2
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...
1
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...
2
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...
1
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,...
0
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. ...
0
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...
3
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.