Solved

Definig Custom Item Templates in VS 2005 Web Projects

Posted on 2007-03-21
3
337 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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