How to use T4 to generate strongly-typed navigation class in ASP.NET

In this article, Kirill Chilingarashvili demonstrates how to use a T4 template to generate a navigation class in ASP.NET. This class contains nested classes that represent folders and string constants that represent user control (.ascx) files in the application. Using such navigation class helps to avoid hard-coding file paths as string literals and since it is automatically generated there is no need to maintain string constants manually.

About T4

T4 (Text Template Transformation Toolkit) is a template-based code generation engine. It is available in Visual Studio 2008 and as a download in DSL and GAT toolkits for Visual Studio 2005. T4 engine allows you to use ASP.NET-like template syntax to generate C#, T-SQL, XML or any other text files.

For more information about T4, check out my previous article.

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!