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)
{
writer.Write(@"
<html>
<head></head>
<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
base.Render(writer);
writer.Write(@"
</td>
<close all tables. Include html code for footers, etc>
</body></html>
");
}
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>
forums