Do more with your ASP.NET Page Template
page 2 of 9
by Sajid Rehman
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 30728/ 73

How do I create my page Template?


How do I create my page Template?

Create a class that inherits from System.Web.UI.Page.

Override the Render() method –

protected override void Render(HtmlTextWriter writer)





<include html code for header, logo, left menu, tables (up to the point where your aspx form is to be shown)>


// this is responsible for the generation of you aspx





<close all tables. Include html code for footers, etc>




The above code is the simplest way to create a page template.

Now, make sure all your aspx pages have their code-behind inheriting from the class you have just created.

Also, be sure to

  • Remove all <HTML>, <HEAD>, <BODY>, <TABLE> start & end tags from your aspx source. Basically, remove anything that you have already included in the Render() method.
  • Remove all absolute positioning style attributes from your aspx source, i.e. code for a label that looked like

<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server">Label</asp:Label>

should now look like

<asp:Label id="Label1" runat="server">Label</asp:Label>


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 

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

©Copyright 1998-2021  |  Page Processed at 2021-03-02 9:39:06 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search