Creating and Using Own Templates using ASP
When ever the scripts on your pages will become complex, Templates are the best solution.
working on ASP Templates is quite easy,
1. Stick to page layout
eg:. pregare a static html page with your requirements
2. change the content part of each division to one standard identification string
eg:.
<div id='leftpanel'>
<ul>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
</ul>
</div>
where ul is the dynamically generated content
change it to
<div id=’leftpanel’>
<!-leftpanel->
</div>
3. Now write a function with the final html code
template = “”
template = template & “<!-title->”
template = template & “”
template = template & createBody()
template = template & “”
template = template & “”
htmltemp = template
End Function
FUNCTION createBody()
bodytext =bodytext &”<!-header->”
bodytext =bodytext & “<!-menunavigation->”
-
-
-
createBody=bodytext
End Function
like this go on creating functions for the necessery blocks and combine them to form a dynamic HTML content
finally integrate this in the page where needed as shown below :
File : finaltemplate.asp
thebody = “<CENTER> This is the template! </CENTER>”
template = htmltemp()
template = Replace(template, “<!-title->”, thetitle)
template = Replace(template, “<!-body->”, thebody)
Response.Write template
Function htmltemp()
template = “<HTML>”
template = template & “<TITLE><!-title-></TITLE>”
template = template & “<BODY>”
template = template & “<!-body->”
template = template & “</BODY>”
template = template & “</HTML>”
htmltemp = template
End Function
%>




