Are Master Pages Really Worth The Effort ?

J

Just Me

I can see master pages being useful if one wants some fragil or complex web
design which one does not want to have altered, but thats were it stops as
far as I can see.

Master Pages Plus

1.) Consistent Design.


Master Pages Minus

1.) Makes it difficult to access properties or function on the Master, one
has to either use FindControl or has to cast to the appropriate type in
order to gain access.

2.) ID's on the content page become ctl_theplaceholderName_originalID. this
means that style sheets get messy when trying to group id's in a common
class. ( this is the way user controls work anyway, but I would have thought
that It would have been possible to check the ID's were not in use in the
master and allow them to remain as originally names in case of no
duplicates.?!? or at least give that as an option ?

IE

form#FormName .groupingClass #ctl_theplaceholderName_originalID{}

instead of

form#FormName .groupingClass #originalID {}



Comments, im sure I have missed loads of positives, but I would like
discussion on this please.

Thanks
 
B

bruce barker

you master page should implement an interface (or multiple). you pages
should all have a base page. the base page can expose a properly cast
master. it all about object oriented design. in the .net world you
should follow the interface design also.

-- bruce (sqlwork.com)
 
M

Michael Nemtsev

Hello Just Me" news.microsoft.com,


J> I can see master pages being useful if one wants some fragil or
J> complex web design which one does not want to have altered, but thats
J> were it stops as far as I can see.
J>
J> Master Pages Plus
J>
J> 1.) Consistent Design.
J>
J> Master Pages Minus
J>
J> 1.) Makes it difficult to access properties or function on the
J> Master, one has to either use FindControl or has to cast to the
J> appropriate type in order to gain access.

You can use event-driver approach for this, making interactions loosely coupled



---
WBR, Michael Nemtsev [C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
 
J

Just Me

Yes, I know how to set the master type and cast it, but it still means that
you you need to have at least one function in the content page in order to
avoid casting each time.
 
M

Mark Rae

you master page should implement an interface (or multiple).

Yes indeed.
you pages should all have a base page. the base page can expose a properly
cast master. it all about object oriented design.

Absolutely! That's the crucial element.
 
G

Guest

Hi there,

DO NOT use client id in CSS stylesheet for any server control- NEVER!!!. It
is not quaranteed renered client id is the same as ID. Use named classes
instead. in addtion, you don't have to cast master property everytime you
access it as you can add @MasterType directive to every web form that has a
master page.
 
J

Just Me

You can use style sheets, I have done it. You simply assign the css class
instead of using ID selectors.
 
J

Joerg Jooss

Thus wrote Just Me" news.microsoft.com,
I can see master pages being useful if one wants some fragil or
complex web design which one does not want to have altered, but thats
were it stops as far as I can see.

Master Pages Plus

1.) Consistent Design.

Master Pages Minus

1.) Makes it difficult to access properties or function on the Master,
one has to either use FindControl or has to cast to the appropriate
type in order to gain access.

You can have strongly typed MasterPages -- use <%@MasterType VirtualPath="..."
%> to reference your MasterPage by URI, or <%@MasterType TypeName="..." %>
to do it by CLR type.

Cheers,
 
J

Just Me

Thanks Joerg



Joerg Jooss said:
Thus wrote Just Me" news.microsoft.com,


You can have strongly typed MasterPages -- use <%@MasterType
VirtualPath="..." %> to reference your MasterPage by URI, or <%@MasterType
TypeName="..." %> to do it by CLR type.

Cheers,
 
G

Guest

That's exactly what i said :D you shouldn't use control.ID

<asp:TextBox runat=sever ID=txtName/>

#txtName {
width: 100px;
}

but named classes

..MyCssClassName{
width: 100px;
}

<asp:TextBox runat=sever ID=txtName CssClass="MyCssClassName"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top