Page Templating for Web Applications
page 4 of 5
by J. Ambrose Little
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 29898/ 57

Drawbacks
 
The are only three drawbacks of using this scheme that I am aware of. The first is that it can complicate things if you have more than one form, as far as the UI is concerned, that might require a separate "default button." The good news is that there are at least a few workarounds for this, and if interest is expressed, I will expand in a part two of this article on how to do that.

The second drawback is that ASPX Intellisense is not enabled for most of the server controls when you remove the HTML and BODY tags from the ASPX (which you should if you're using this scheme). There are a number of workarounds for this. You can read about a creative one at Paul Wilson's Page Templates: Designer Issues. I've found that temporarily adding the BODY tags enables Intellisense. You can them just remove them or comment them out when you put the page into production, although I've found that leaving them there doesn't appear to hurt anything. Hopefully, the next release of VS.NET will account for this and provide Intellisense on such ASPX pages, as they do now for ASCX pages that also do not have HTML or BODY tags.

The third is that you cannot use ASP-style code blocks (e.g., <% ... %>) on the page.  For whatever reason, ASP.NET marks control collections as read-only as soon as you add a literal with code blocks, so further modification cannot be made to the tree.  I have asked around extensively and have yet to find a solution to this.  A workaround is to simply not use code blocks.  There are a few instances where using code blocks might make sense, but generally I think it's a bad habit and holdover from the ASP model that should be avoided.

 


View Entire Article

User Comments

Title: An idea   
Name: Hans
Date: 2007-01-29 5:17:42 AM
Comment:
If you want intellisene without having to add body tags to the pages you can go into Tools -> Options -> Text Editor -> File Extension and add the "aspx" extension to the User Control Editor.

Cheers,
H
Title: Rendering Controls   
Name: Ambrose
Date: 2005-09-23 10:08:57 AM
Comment:
John, that sounds like a big question and one that isn't entirely clear (to me anyways). You might try asking over at the ASP.NET Forums; it's better suited to general questions.
Title: good article   
Name: John
Date: 2005-09-23 12:16:25 AM
Comment:
how do we render the controls to the web page and still be able to interact with the server as if it is a web server control.
Title: excellent   
Name: A Anderson
Date: 2005-09-20 10:16:29 PM
Comment:
Excellent work. I would like to express my interest in your part two. :-) thanks.
Title: Good Ideas!   
Name: Greg Olsen
Date: 2004-12-06 5:47:11 AM
Comment:
Got some great ideas/code from this on how to add user controls to build up a page using templates and inheritance.
Also see http://www.codeproject.com/aspnet/page_templates.asp
for more great info on page inheritance and asp.net templates. These two sites allow for any beginner to architect a good website structure.
Title: Very good   
Name: Yao Liu
Date: 2004-11-02 3:44:22 PM
Comment:
Helps me solve the view state problem
Title: Nicewhan bruvva!   
Name: Nik
Date: 2004-10-21 8:49:07 PM
Comment:
Good article. I'll find this very useful.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-19 9:28:39 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search