Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Do you prefer Master Page or User Controls?

Reply
Thread Tools

Do you prefer Master Page or User Controls?

 
 
Cirene
Guest
Posts: n/a
 
      05-20-2008
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.


 
Reply With Quote
 
 
 
 
jc
Guest
Posts: n/a
 
      05-20-2008
On 20 mayo, 06:22, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:
> "Cirene" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> >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.

 
Reply With Quote
 
 
 
 
David Wier
Guest
Posts: n/a
 
      05-20-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On 20 mayo, 06:22, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:
> "Cirene" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...

<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.


 
Reply With Quote
 
Madhur
Guest
Posts: n/a
 
      05-20-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> On 20 mayo, 06:22, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:
>> "Cirene" <(E-Mail Removed)> wrote in message
>>
>> news:(E-Mail Removed)...

> <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.
>
>


 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      05-20-2008
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "jc" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      05-20-2008
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>>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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> On 20 mayo, 06:22, "Mark Rae [MVP]" <(E-Mail Removed)> wrote:
>>> "Cirene" <(E-Mail Removed)> wrote in message
>>>
>>> news:(E-Mail Removed)...

>> <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.
>>
>>

>





 
Reply With Quote
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      05-22-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Access Master Page Controls from page.aspx doesn't inherit from master SerpentKiss2010 ASP .Net 0 04-06-2011 02:46 PM
Setting the value of a Master page's control's property using a property of the Master page Nathan Sokalski ASP .Net 25 03-04-2010 03:42 AM
Can a master page be built from another master page Zeba ASP .Net 1 02-22-2007 10:55 AM
seeking servlet "Master" keep getting "Master/servlet/Master" not found. Tomcat 5.0.25 Doug McCann Java 1 08-05-2004 09:16 PM
do you prefer Pix as your firewall or ? Kerry Cisco 5 01-24-2004 10:23 PM



Advertisments