Welcome to WebmasterWorld Guest from 54.196.144.100

Forum Moderators: ocean10000

Message Too Old, No Replies

Simple Syntax Question

how to add an HTML tag to asp code

     

MattAtWork

12:16 am on Dec 7, 2004 (gmt 0)

10+ Year Member



I have the following piece of code on a page which returns the date modified and my name.

<%
Dim FileObj
Set FileObj = Server.CreateObject ("LastMod.FileObj")
FileObj.TimeFormat = ""
FileObj.DateFormat = "ddd, mmm d yyyy"
Response.Write "This page was last modified by Matt" & FileObj.LastModified (server.mappath(Request.ServerVariables("PATH_INFO"))) &"<br>"
%>

I want my name to launch a blank email (like using <a href="mailto:matt@example.com">Matt</a>)

Obviously straight HTML won't work, so what would I have to add to the code to make this work?

[edited by: Xoc at 5:30 pm (utc) on Dec. 7, 2004]

Dreamquick

12:34 am on Dec 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two ways spring to mind...

[quote]<% 
Dim FileObj
Set FileObj = Server.CreateObject ("LastMod.FileObj")
FileObj.TimeFormat = ""
FileObj.DateFormat = "ddd, mmm d yyyy"

Response.Write "This page was last modified by <a href=""mailto:matt@example.com"">Matt</a>) " & FileObj.LastModified(Server.MapPath(Request.ServerVariables("PATH_INFO"))) &"<br>"
%>[/quote]


(Note the use of pairs of double quotes inside the string)

...or if you're not really a big fan of inline Response.Write's (I know I'm not)...

[quote]<%
Dim FileObj
Set FileObj = Server.CreateObject ("LastMod.FileObj")
FileObj.TimeFormat = ""
FileObj.DateFormat = "ddd, mmm d yyyy"
%>
This page was last modified by <a href="mailto:matt@example.com">Matt</a>)
<%= FileObj.LastModified(Server.MapPath(Request.ServerVariables("PATH_INFO"))) %><br>[/quote]

...either way remember to Set FileObj = Nothing when you're done.

- Tony

[edited by: Xoc at 5:31 pm (utc) on Dec. 7, 2004]

MattAtWork

1:28 am on Dec 7, 2004 (gmt 0)

10+ Year Member



Thanks for that - is it the same rule with any HTML? Add the double quotes?

Dreamquick

4:05 pm on Dec 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You only need a pair of double quotes if you are attempting to use double quotes inside a string. Outside of strings the double quote should have little-to-no effect on the ASP engine so you should be able to use it as normal.

Normally a double quote acts as a delimiter for a string, so having one part way through a string would causes the ASP engine to raise an error because it would encounter that quote and assume the string had ended and that the rest of the string belonged to something else.

By using a pair of quotes you "encode" the quote, implying that you want it to be part of the content of the string rather than a delimiter.

- Tony