Codesmith in the use of the process, we often appear the same method in a different page call, if we write a method on each page, then the code is very large, and if you need to change in the future in each page to modify, it is undoubtedly the life of exhausting, If there is a better way to do so. The following are available in two ways:
Method One:
1. Create the public class Comm.cs, the contents of the class are as follows:
Public string GetData () { return"ABC";}
2. The content of the CST file is called as follows:
<%@ codetemplate Language="C #"Targetlanguage="Text"SRC=""Inherits=""Debug="False"CompilerVersion="v3.5"Description="Template description here." %><%=GetData ()%><Scriptrunat= "template"><!--#include file="Comm.cs" - //referencing public classes</Script>
Method Two:
1. Create the public class Comm.cs, the contents of the class are as follows:
using System; using System.Text; namespace common.data{ publicclass Comm { publicstring getData () { return"ABC"; }} }
2. The content of the CST file is called as follows:
<%@ codetemplate Language="C #"Targetlanguage="Text"SRC=""Inherits=""Debug="False"CompilerVersion="v3.5"Description="Template description here." %><%@ Assembly SRC="Comm.cs"%> <%--Reference CS--%><%@ Import Namespace="Common.data" %> <%--Reference Namespaces--%><%=Com.getdata ()%> <Scriptrunat= "template">Comm com=NewComm ();</Script>
Codesmith public class Maintenance