Creating a template in dot net

J

jen_designs

I am trying to create a template in dot net. All the articles I have
read on the net are rather confusing. I need a simple solution to
create a header and a footer on each page. Can someone point me into
the right direction.

I started off creating a file template.cs:

using System;
using System.Web;
using System.Web.UI;

protected override void OnInit(EvantArgs args)
{
this.Controls.AddAt(0, LoadControl("header.ascx"));
base.OnInit(e);
this.Controls.Add(LoadControl("footer.ascx"));
}

then in the aspx page I did the following:
<%@ Page Language="C#" ContentType="text/html"
ResponseEncoding="iso-8859-1" Codebehind="template.cs" %>
This is the main content

does the template.cs need to be compiled?

Any thoughts?
 
S

Steve C. Orr [MVP, MCSD]

You can create a Visual Studio template using the information in the
following link, although it's not nearly as easy as it should be.
Here are the details:
http://www.sellsbrothers.com/writing/default.aspx?content=projectitemtemplates.htm

In Visual Studio 2005 creating templates will be much easier. There will
also be Master Pages that will allow all your pages to inherit a common
structure.
http://www.c-sharpcorner.com/Code/2004/May/MasterPages.asp

Until then you might want to consider simply create a header user control
and a footer user control and dragging them onto each page and the top and
bottom respectively.
http://SteveOrr.net/faq/usercustom.aspx
 

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

Top