Click here to Skip to main content
13,450,884 members (54,431 online)
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 18 Sep 2013

Creating Reusable Page template

, 23 Oct 2013
Rate this:
Please Sign up or sign in to vote.
Here we’ll learn how to create a page template of our own that is reusable.


In this article we'll built a customized page template instead of using the built-in Web Form Template.


When developing any web application we most of the times use the built-in Web Form that's with the Visual Studio. But What if we want to have a Web Form that we will design as we want and keep it as a template for reuse. So lets do something like that by following the steps below.


  1. First of all Open VS2012, click on New Project on start page or go to File ->New -> Project.


  1. From the left bar Templates select Visual C# -> Web and then in right side select ASP.NET Empty Web Application. Let’s name our application MyWebApplication and set the location of it. Then Press OK.   

  1. From Solution Explorer right click on the project template and select New Item.

  1. Click on Web Form and name it MyWebForm.aspx and click Add.  


  1. In the Markup View set the <title> attribute as follows <title>My Web Form</title>, add <h1>Hello everyone, this is my web form</h1> inside the <div></div> that’s within the <form></form>.So now what if you want this MyWebForm.aspx to be the default Web Form that you can use when you want to add a new one. Save all your changes.  

  1. Go to File -> Export Template, select Item template option from the radio buttons and from the DropDownList select the project from which you would like to create the template. In our case it’s MyWebApplication. Click Next.

  1. Select the item that you want to export as item template. In our case its MyWebForm.aspx . Click Next.

  1. From the select item reference dialogue select nothing. Click Next.

  1. From Select Template Option dialogue give Template Name as MyDefaultWebForm and a description about that template. And check both the checkboxes below. Click Finish
  1. Check if the folder exists here : C:\Users\helloBug\Documents\Visual Studio 2012\Templates\ItemTemplates Change helloBug with your User name.  

  1. Now right click on the Project Template Add New Item and see your template has been added in Visual C#. You’ll also find the description on the right side.  

  1. Click on MyDefaultWebForm1 template on right side name it as you like. I’ll take the default one. And click Add.
  2. It might show you a warning. You might read it. To Continue Click Trust.

So this is it. Now you have your own page template to use.

Note: you may have to restart VS and reopen your website for the template to appear.

Hope you learned something. Thank you.  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ashad Shanto
Software Developer Secure Link Services
Bangladesh Bangladesh
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180318.3 | Last Updated 23 Oct 2013
Article Copyright 2013 by Ashad Shanto
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid