hyperlink in asp

J

Jeff

Hey gang.

i have this

Response.Write Replace(Rs("Event_Details") & " ", vbCrLf, "<BR>") & vbCrLf

coming from access db.

how can i get that to make a hyperlink clickable as well??

Thanks
 
M

Mike Brind

Jeff said:
I don't mind searching, but I can't find the key words to find what I am
looking for.
Any ideas?

This is pretty basic stuff. How would you make a hyperlink in html?
Then how would you response.write that?
 
J

Jeff

I understand that, but I don't understand how to make it read a text block,
from a DB, and make it show clickable links, when needed.

Back to the drawing board i guess..lol
 
B

Bob Lehmann

lol

Bob Lehmann

Jeff said:
I understand that, but I don't understand how to make it read a text block,
from a DB, and make it show clickable links, when needed.

Back to the drawing board i guess..lol
 
M

Mike Brind

From the page in the link:

"People seem to act like this is some sort of mystical and complex
process and they couldn't be farther from the truth. Like I keep
telling everyone ASP is just dynamically created HTML and making a
hyperlink is accomplished by mixing HTML tags with the ASP variables.
It's very simple to make a hyperlink."

Hmmm.... so your discombobulation over hyperlinks appears to be shared
by others. I shall endeavour to be a little more understanding in
future :)
 
E

Evertjan.

Jeff wrote on 26 mei 2006 in microsoft.public.inetserver.asp.general:

[please do not toppost on usenet]
I give up. Seems like this one is too easy, yet it keeps eluding me.

You cannot get that to make a hyperlink clickable,
as a hyperlink is clickable by itself.
 
B

Bob Barrows [MVP]

Jeff said:
I give up. Seems like this one is too easy, yet it keeps eluding me.

Why don't you tell us
1. What is in Rs("Event_Details") ?
2. What you want to see in the source sent to the browser? (what one would
see when selecting View Source)
 
J

Jeff

Ok. I went about this a different way. I had an old script that changed
spaces, <br>'s and stuff... so i went with that, then used a little html,
and the result is this, and it works.
<br>
<font face="Verdana,Arial" size="1"><% myString =
Replace(Rs("Event_Details"), vbCrLf, " <br> ")%><%=
InsertHyperlinks(myString)%><br>
&nbsp;</font></p>


thanks again.
Bob, thanks for replying, and what it was showing in the source, was the
link without it being clickable. but with this code it is.

Thanks again.
 
M

Mike Brind

Or, you could have used the obvious:

<a href=""><%=mystring%></a>

There is no such thing as a link that isn't clickable, as Evertjan has
already pointed out. There is a string written to a page, or there is
a string encapsulated in an <a href> tag which forms a hyperlink. As I
said - basic html.
 
M

Mike Brind

Oh, wait a minute... let me guess...

Event Details is a memo field that contains some text describing an
event, and also includes email and/or web addresses, and it is these
that you want to identify and turn into hyperlinks. Is that right?
You don't want to turn the whole field into a hyperlink, do you?

If this is the case, and you had explained your problem properly at the
beginning, I would have posted this code several days ago:

<%
function create_links(strText)
strText = " " & strText
strText = ereg_replace(strText, "(^|[\n ])([\w]+?://[^ ,""\s<]*)",
"$1<a href=""$2"" target=""_blank"">$2</a>")
strText = ereg_replace(strText, "(^|[\n ])((www|ftp)\.[^ ,""\s<]*)",
"$1<a href=""http://$2"" target=""_blank"">$2</a>")
strText = ereg_replace(strText, "(^|[\n
])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)", "$1<a
href=""mailto:$2@$3"">$2@$3</a>")
strText = right(strText, len(strText)-1)
create_links = strText
end function

function ereg_replace(strOriginalString, strPattern, strReplacement)
' Function replaces pattern with replacement
dim objRegExp : set objRegExp = new RegExp
objRegExp.Pattern = strPattern
objRegExp.IgnoreCase = True
objRegExp.Global = True
ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
set objRegExp = nothing
end function
%>

which you call like this:
<%
Response.Write create_links(myString)
%>

In fact, I tend to use it on data prior to inserting it into a
database, which means the function isn't called every time a user
requests a page which contains text that might or might not have email
or web addresses in it that need to be turned into links. Does your
InsertLinks() function do the same thing?

--
Mike Brind


Mike said:
Or, you could have used the obvious:

<a href=""><%=mystring%></a>

There is no such thing as a link that isn't clickable, as Evertjan has
already pointed out. There is a string written to a page, or there is
a string encapsulated in an <a href> tag which forms a hyperlink. As I
said - basic html.

--
Mike Brind

Ok. I went about this a different way. I had an old script that changed
spaces, <br>'s and stuff... so i went with that, then used a little html,
and the result is this, and it works.
<br>
<font face="Verdana,Arial" size="1"><% myString =
Replace(Rs("Event_Details"), vbCrLf, " <br> ")%><%=
InsertHyperlinks(myString)%><br>
&nbsp;</font></p>


thanks again.
Bob, thanks for replying, and what it was showing in the source, was the
link without it being clickable. but with this code it is.

Thanks again.
http://"><%=mystring%></a> There i...s code it is. Thanks again. [/QUOTE][/QUOTE][/QUOTE]
 
J

Jeff

right... this is what i have at the top of the page
<%

Function InsertHyperlinks(inText)
Dim objRegExp, strBuf
Dim objMatches, objMatch
Dim Value, ReplaceValue, iStart, iEnd

strBuf = ""
iStart = 1
iEnd = 1
Set objRegExp = New RegExp

objRegExp.Pattern = "\b(www|http|\S+@)\S+\b" ' Match URLs and emails
objRegExp.IgnoreCase = True ' Set case insensitivity.
objRegExp.Global = True ' Set global applicability.
Set objMatches = objRegExp.Execute(inText)
For Each objMatch in objMatches
iEnd = objMatch.FirstIndex
strBuf = strBuf & Mid(inText, iStart, iEnd-iStart+1)
If InStr(1, objMatch.Value, "@") Then
strBuf = strBuf & GetHref(objMatch.Value, "EMAIL", "_BLANK")
Else
strBuf = strBuf & GetHref(objMatch.Value, "WEB", "_BLANK")
End If
iStart = iEnd+objMatch.Length+1
Next
strBuf = strBuf & Mid(inText, iStart)
InsertHyperlinks = strBuf
End Function


Function GetHref(url, urlType, Target)
Dim strBuf

strBuf = "<a href="""
If UCase(urlType) = "WEB" Then
If LCase(Left(url, 3)) = "www" Then
strBuf = "<a href=""http://" & url & """ Target=""" & _
Target & """>" & url & "</a>"
Else
strBuf = "<a href=""" & url & """ Target=""" & _
Target & """>" & url & "</a>"
End If
ElseIf UCase(urlType) = "EMAIL" Then
strBuf = "<a href=""mailto:" & url & """ Target=""" & _
Target & """>" & url & "</a>"
End If

GetHref = strBuf

End Function
%>

and the
<% myString = Replace((event_details), vbCrLf, " <br> ")%><%=
InsertHyperlinks(myString)%>

is the output for the field

if all that was in there was the url, i could have done that with no
problem. the problem was converting what i posted originally into a
response.write so i avoided that, and made it into html with some script.
thanks for all the help :)


Mike Brind said:
Oh, wait a minute... let me guess...

Event Details is a memo field that contains some text describing an
event, and also includes email and/or web addresses, and it is these
that you want to identify and turn into hyperlinks. Is that right?
You don't want to turn the whole field into a hyperlink, do you?

If this is the case, and you had explained your problem properly at the
beginning, I would have posted this code several days ago:

<%
function create_links(strText)
strText = " " & strText
strText = ereg_replace(strText, "(^|[\n ])([\w]+?://[^ ,""\s<]*)",
"$1<a href=""$2"" target=""_blank"">$2</a>")
strText = ereg_replace(strText, "(^|[\n ])((www|ftp)\.[^ ,""\s<]*)",
"$1<a href=""http://$2"" target=""_blank"">$2</a>")
strText = ereg_replace(strText, "(^|[\n
])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)", "$1<a
href=""mailto:$2@$3"">$2@$3</a>")
strText = right(strText, len(strText)-1)
create_links = strText
end function

function ereg_replace(strOriginalString, strPattern, strReplacement)
' Function replaces pattern with replacement
dim objRegExp : set objRegExp = new RegExp
objRegExp.Pattern = strPattern
objRegExp.IgnoreCase = True
objRegExp.Global = True
ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
set objRegExp = nothing
end function
%>

which you call like this:
<%
Response.Write create_links(myString)
%>

In fact, I tend to use it on data prior to inserting it into a
database, which means the function isn't called every time a user
requests a page which contains text that might or might not have email
or web addresses in it that need to be turned into links. Does your
InsertLinks() function do the same thing?

--
Mike Brind


Mike said:
Or, you could have used the obvious:

<a href=""><%=mystring%></a>

There is no such thing as a link that isn't clickable, as Evertjan has
already pointed out. There is a string written to a page, or there is
a string encapsulated in an <a href> tag which forms a hyperlink. As I
said - basic html.

--
Mike Brind

Ok. I went about this a different way. I had an old script that changed
spaces, <br>'s and stuff... so i went with that, then used a little
html,
and the result is this, and it works.
<br>
<font face="Verdana,Arial" size="1"><% myString =
Replace(Rs("Event_Details"), vbCrLf, " <br> ")%><%=
InsertHyperlinks(myString)%><br>
&nbsp;</font></p>


thanks again.
Bob, thanks for replying, and what it was showing in the source, was
the
link without it being clickable. but with this code it is.

Thanks again.
I give up. Seems like this one is too easy, yet it keeps eluding me.



Hey gang.

i have this

Response.Write Replace(Rs("Event_Details") & " ", vbCrLf, "<BR>") &
vbCrLf

coming from access db.

how can i get that to make a hyperlink clickable as well??

Thanks

http://"><%=mystring%></a> There i...e as well?? Thanks [/QUOTE][/QUOTE] [/QUOTE][/QUOTE][/QUOTE]
 

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,223
Latest member
Jurgen2087

Latest Threads

Top