Solved

Definig Custom Item Templates in VS 2005 Web Projects

Posted on 2007-03-21
3
336 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
ID: 18765696
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
ID: 18769957
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
ID: 18779944
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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