ITTreats.com
Enter your Search term and Hit "Enter"

Sat, 20 Mar 2010 12:16:55 PM +00:00

Latest 'ITTreats'


Creating and Using Own Templates using ASP

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

Function htmltemp()
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

<% thetitle = “HTML Template”
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

%>