HTML Page Templates in ASP

S

Serge

Is this affective way using HTML Templates in ASP:

i have html template file with <<TAG1>> .. <<TAGN>> in places, where i want
to insert some data
then i generate this data in asp

Dim d ' Create a variable.
Set d = CreateObject("Scripting.Dictionary")
d.Add "TAG1", "Athens" ' Add some keys and items.
d.Add "TAG2", "Belgrade"
d.Add "TAG3", "Cairo"

, open html template, replace each <<TAGx>> with generated data
(d.Item("TAGx") ),
and print it with Response.Write

Or there is any other usual methods to use templates?
 
M

Mike

Hi

I usually simplyify this by surrounding the HTML "placeholders" with
the hash character:

- - -

Thank you for purchasing #PolicyType# from our website

- - -

Then I loop through the fields in the recordset and do the
replacement:

- - -

For Each str_ItemFound In obj_RecordSet1.Fields
str_Value = obj_RecordSet1(str_ItemFound.Name)
If IsNull(str_Value) Then str_Value = ""
Select Case str_ItemFound.Name
Case "Premium"
str_Value = FormatCurrency(str_Value)
End Select
str_Contents = Replace(str_Contents,"#" & str_ItemFound.Name &
"#",str_Value)
Next

- - -

Seems to be fairly efficient as long as you are not handling masses of
data

MK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top