homepage Welcome to WebmasterWorld Guest from 174.129.76.87
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Simple Syntax Question
how to add an HTML tag to asp code
MattAtWork

5+ Year Member



 
Msg#: 2337 posted 12:16 am on Dec 7, 2004 (gmt 0)

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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2337 posted 12:34 am on Dec 7, 2004 (gmt 0)

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

5+ Year Member



 
Msg#: 2337 posted 1:28 am on Dec 7, 2004 (gmt 0)

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

Dreamquick

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2337 posted 4:05 pm on Dec 7, 2004 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved