473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Creating a template in dot net

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?

Nov 19 '05 #1
2 1619
If you use Src="template.cs" instead of Codebehind="template.cs", then
the cs file will compile when the page is requested.

You'll have a compiler error though, if the source you were showing
was the entire contents of the file. Methods have to exist inside of a
class declaration.

Have you tried the following article?
http://msdn.microsoft.com/library/de...rockASPNET.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/

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?


Nov 19 '05 #2
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...mtemplates.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/20...asterPages.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

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
<je*********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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?

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: aynka2000 siva | last post by:
need to make a letter template using xml in vb.net eg after creating template when use clicks a button in form template must be loaded there he must able to type anything such as <name></name> ...
1
by: lempertay | last post by:
I have an existing MS Access database with just over 2,000 records. I have a group that wants to use the database except with their own data. So basically I need to provide them the front end...
1
by: suzy | last post by:
hi, i have created a aspx page template by creating a template.cs file which inherits from the page class. In this file I override the OnInit event and create a template in the form of a...
2
by: Nicole | last post by:
I am creating template columns programmatically. I have read the msdn article on this and I'm so close. Article:...
1
by: Luis Esteban Valencia | last post by:
Hi all, I tried doing this with the aid of the following document:...
1
by: Barkster | last post by:
I've been using Dreamweaver to create my php pages and love the functionality but when I start modifying code I start wondering if I should be something else because it always throws off the...
3
by: andrej | last post by:
Hi, I'm working on a project in VB6 where I want to use something like templates saved in my database with customization of the template like selection of words and in specific fields to fill with...
0
by: imranabdulaziz | last post by:
Hi all, I am using asp.net and C# Visual studio 2005. Let me explain the scenario. I have stored procedure which return very no of column based on condition. Becoz I have to show columnwise...
1
by: apking | last post by:
what is the basic for creating template.
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.