6/23/2004

ASP.Net Headers/Templates

Filed under: General — russell @ 4:00 am

Found a good article on how to use "old fashioned" include style headers and templates with .Net. Unlike many of the "template" engine for .Net this one is overly simple and works like the old ASP (and PHP for that matter) includes.

Compliments of John Timney:

Traditional #include is not really a good option for the OO nature of
asp.net. The correct approach is to use user controls, but they can be very
simple to implement.

Add this line to the top of your aspx page:

includeme.ascx is the equivalent of the old include file with your HTML
etc, in my case it is a navigation menu

Code:
< %@ Register TagPrefix="myProject" TagName="includedthing"
Src="includeme.ascx" %>

Then to position the include file in the page, add the line below to your ASPX
page where you want it positioned

Code:
<myproject :includedthing ID="myfirstinclude" runat="server" />

^ Note in the above tag myProject:includething reference the TagPrefix and TagName from the ascx declaration (the line with Src=).

* If you are using the VS IDE you can simply drag and drop the .ascx file on your page where it should be included.

http://www.dotnet247.com/247reference/msgs/36/181591.aspx


No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Couldn't find your convert utility. Check that you have ImageMagick installed.