Here is an example where we have a variable that is a hyperlink. This variable could come from a database query
<% MyHyperLink = "http://www.yoursite.com" %>
Now to make a hyperlink on your ".asp" page we simply do this
<a href="<% =MyHyperLink %>"><% =MyHyperLink %></a>
or you could build the string and Response.Write it to the page if you like.
<% Response.Write("<a href=""" & MyHyperLink & """>" & MyHyperLink & "</a>") %>
To take this even further let's say your hyperlink info may not contain the "http://" info.
Here is a very simple example of testing for that and dealing with it.
<% If InStr(LCase(MyHyperLink) ,"http://") = 0 Then MyHyperLink = "http://" & MyHyperLink End If %>
<a href="<% =MyHyperLink %>"><% =MyHyperLink %></a>
Basically we use the LCase function to make the hyperlink we are testing lowercase just in case "http://" was spelled using any capital letters. Then we use the InStr function to see if the string "http://" is in the hyperlink. If it is not we simply add it to it. In this case we are not taking into account the possibility of a "https://" secure hyperlink, but you get the general idea.
The next example is an email hyperlink.
<% MyEmailAddress = "someone@somesite.com" %>
To make an email hyperlink with that we simply do this.
<a href="mailto:<% =MyEmailAddress %>"><% =MyEmailAddress %></a>
or this
<% Response.Write("<a href=""mailto:" & MyEmailAddress & """>" & MyEmailAddress & "</a>") %>
The thing to remember about ASP is that an understanding of HTML tags is very important. A lot of people tend to put all their faith in their WYSIWYG editors and have no idea how to write HTML by hand. Take some helpful advice and learn HTML tags. You cant work with ASP and make anything worthwhile if you can not understand and write basic HTML.





MultiQuote


|