Solved

Definig Custom Item Templates in VS 2005 Web Projects

Posted on 2007-03-21
3
333 Views
Last Modified: 2013-11-26
Hi there

I am trying to create a custom item/page template for my web project in VISUAL STUDIO 2005. I am using the following article as a basis:

http://weblogs.asp.net/scottgu/archive/2005/09/09/424780.aspx

The problem I am getting is that the Marker I am setting in the inherits property of the aspx file and the class name in the aspx.cs file are not being substituted with the file name that I designate when I use the template to add a new web page to my project.

The marker is setup as follows:

ASPX file:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" CodeFile="default_template.aspx.cs" Inherits="$pagename$" Title="Untitled Page" %>


ASPX.CS file:
public partial class $pagename$ : CustomBasePage

When I create my new web page using the template, the "$pagename$" remains meaning I have to manually edit it rather than it substituting automatically when the page is created.

Anyone know why this might be happening?

Cheers
0
Comment
Question by:yvsupport
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Webstorm earned 500 total points
Comment Utility
Hi yvsupport,

Your template must use specific marker name
see http://msdn2.microsoft.com/en-us/library/eehb4faa(VS.80).aspx

So, use $safeclassname$ instead of $pagename$
0
 

Author Comment

by:yvsupport
Comment Utility
Hi there

I didn't know those names were specifically defined. I tried $safeclassname$ but that didn't work either so I tried $safeitemname$, which is the one used in the article that I mentioned in my original post and amazingly it works. Much strangeness ..... Anyway, I shall mark your comment as the solution as you certainly pointed me in the right direction :)

Cheers
0
 
LVL 13

Expert Comment

by:Webstorm
Comment Utility
In fact, the template parameter name depends on which action will generate the value :
$safeclassname$  when you add a new class
$safeitemname$  when you add a new item
...
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now