(c) 2002 Visual Studio Magazine
Fawcette Technical Publications

Issue: September 2002
Section: ASP.NET
Author: Jonathan Goodyear

ASP.NET, C#	Create Your Own Wizard Templates
Listing 1	The wizard templates that come with VS.NET need to be applicable to all development projects, so they're rudimentary. Create your own wizard templates and add the boilerplate code that's specific to your company and its projects.

<%@ Page language="c#" 
	Codebehind="WebForm3.aspx.cs" 
	AutoEventWireup="false" 
	Inherits="TestingStuff.WebForm3" %>
<!DOCTYPE HTML PUBLIC 
	"-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
	<head>
		<title>WebForm3</title>
		<meta name="GENERATOR" Content=
			"Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" 
			content="JavaScript">
		<meta name="vs_targetSchema" content=
"http://schemas.microsoft.com/intellisense/ie5">
	</head>
	<body MS_POSITIONING="GridLayout">
		<form id="WebForm3" method="post" 
			runat="server">
		</form>
	</body>
</html>

ASP.NET, C#	Expand on VS.NET's Web Form Wizard Template
Listing 2	This custom wizard template expands upon the existing Web Form wizard template that comes with VS.NET. It adds the company name and project name to the page title, a place holder for the page name, and a copyright notice at the bottom of the page. In your own templates, you can add as much code as you need to reduce your workload and add consistency to your pages.

<%@ Page language="c#" Codebehind="$FILENAME$.cs" 
	AutoEventWireup="false" Inherits="$INHERITS$" 
	%>
<!DOCTYPE HTML PUBLIC 
	"-//W3C//DTD HTML 4.0 Transitional//EN" > 

<html>
	<head>
		<title>XYZ Company - MyProject: [!output 
			SAFE_ITEM_NAME]</title>
		<link rel="stylesheet" href=
			"stylesheets/xyz_intranet.css" 
			type="text/css">
		<meta name="GENERATOR" Content=
			"Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name=vs_defaultClientScript content=
			"[!output DEFAULT_CLIENT_SCRIPT]">
		<meta name=vs_targetSchema content=
			"[!output DEFAULT_TARGET_SCHEMA]">
	</head>
	<body MS_POSITIONING=
		"[!output DEFAULT_HTML_LAYOUT]">
	
		<form id="[!output SAFE_ITEM_NAME]" 
			method="post" runat="server">
			<h1>Put title here</h1>
			<hr>
		</form>

		<center>
		<b>Copyright 2002 XYZ Company - All rights 
			reserved.</b>
		</center>
	</body>
</html>

C#	Implement Exception Handling
Listing 3	All projects should implement exception handling, so you might as well create a custom wizard template that implements it. Company descriptions, legal notices, and detailed comment place holders are some other things you might want to consider for your own class library templates.

using System;
using System.Data;
using System.Data.SqlClient;

namespace [!output SAFE_NAMESPACE_NAME]
{
	/// <summary>
	/// XYZ Company - MyProject
	/// This code is for internal purposes only.
	/// [!output SAFE_CLASS_NAME]
	/// </summary>
	public class [!output SAFE_CLASS_NAME]
	{
		public [!output SAFE_CLASS_NAME]()
		{
			try
			{
				//
				// TODO: Add constructor logic here
				//
			}
			catch(Exception ex)
			{

			}
			finally
			{

			}
		}
	}
}
