Solved

Definig Custom Item Templates in VS 2005 Web Projects

Posted on 2007-03-21
3
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 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