preparedHTML code sample by Jeremy zheng

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
July 04, 2001
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Have you been bothered by mixing your asp code with html tag, some times it just causes big mess, preparedHTML separates concerns about program code from concerns about the way a page looks: 

1) HTML should not clutter up program code 
2) Program code should not clutter up HTML 
3) No-one should have to work through somebody else 

Here is the segment of the ASP code:
<%
dim html
function readHTML(fileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile( filename)
html1 = f.ReadAll
f.Close
readHTML=html1
end function

sub placeHolder(name,value)
        replaceString="<!--placeholder:"&name&"-->"
        post1=inStr(html,replaceString)
    if post1>0 then
        html=replace(html,replaceString,value)
    end if
end sub

testpage=Server.MapPath("mypage.htm")
html=readHTML(testpage)
call placeHolder("myname","jeremy")
%>

readHTML function just creates a file system object and returns all the content.
placeHolder is used to replace the string with actually value on your static HTML page,
your static HTML page (mypage.htm) should include code like this:

<a href='<!--placeholder:mylink-->'>Go.. </a>

mylink is variable you want to be replaced.
blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials