A Friend in Need is a Friend in Deed.
Become a Member at ITTreats.com !! Share Your invaluable Experience to Fellow Programmers. Signup, Start Blogging and support fellow Techies.

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

%>

Article Written by : adrevol
( Articles Submitted : 47 Articles Commented : )




Leave a Reply