Andrea Grub
|
| Posted: 12/07/2002, 12:07 AM |
|
Hi
how can i make a database entry in a grid clickable? (Links to external
Pages and/or Mailto actions)
Thanks for your help
Andrea
|
|
|
 |
MikeL
|
| Posted: 12/08/2002, 6:48 AM |
|
http://www.gotocode.com/art.asp?art_id=39&
I have modified the code to work with asp/ccs. Place the following code in
the common.asp file (make sure to save it before closing the page in ccs):
'Create clickable hyperlinks
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
'End create clickable hyperlinks
Add the following before show code to the label that should be clickable. Be
sure to set the field type to label and Data Content Properties to HTML.
' Converts all Hyperlinks to HTML for clickable links
Dim strURLS
strURLS = InsertHyperlinks(<formname>.<fieldname>.Value)
strURLS = Replace(strURLS, vbCrLf, " ")
<formname>.<fieldname>.Value= StrURLS
This code converts any text string starting with www, http or contains @ to
a clickable link. If you need to, you should be able to see how to add https
if neccessary.
MikeL
"Andrea Grub" <a.grub@qwirt.ch> wrote in message
news:assa8t$9bb$1@news.codecharge.com...
> Hi
>
> how can i make a database entry in a grid clickable? (Links to external
> Pages and/or Mailto actions)
>
> Thanks for your help
> Andrea
>
>
>
|
|
|
 |
Andrea Grub
|
| Posted: 12/09/2002, 6:12 AM |
|
MikeL
thanks for helping me.
But it seems that your code does not work under CCS 2.0 Beta1. (Error
500-100 under IIS)
What i'm doing wrong?
Andrea
"MikeL" <dazed_o1o@yahoo.com> schrieb im Newsbeitrag
news:asvm4p$9s6$1@news.codecharge.com...
> http://www.gotocode.com/art.asp?art_id=39&
>
> I have modified the code to work with asp/ccs. Place the following code in
> the common.asp file (make sure to save it before closing the page in ccs):
>
> 'Create clickable hyperlinks
> 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
> 'End create clickable hyperlinks
>
> Add the following before show code to the label that should be clickable.
Be
> sure to set the field type to label and Data Content Properties to HTML.
>
> ' Converts all Hyperlinks to HTML for clickable links
> Dim strURLS
> strURLS = InsertHyperlinks(<formname>.<fieldname>.Value)
> strURLS = Replace(strURLS, vbCrLf, " ")
> <formname>.<fieldname>.Value= StrURLS
>
> This code converts any text string starting with www, http or contains @
to
> a clickable link. If you need to, you should be able to see how to add
https
> if neccessary.
>
> MikeL
>
> "Andrea Grub" <a.grub@qwirt.ch> wrote in message
>news:assa8t$9bb$1@news.codecharge.com...
> > Hi
> >
> > how can i make a database entry in a grid clickable? (Links to external
> > Pages and/or Mailto actions)
> >
> > Thanks for your help
> > Andrea
> >
> >
> >
>
>
|
|
|
 |
Gary D
|
| Posted: 12/09/2002, 10:51 AM |
|
I do this using the before show event. I have a field that has email
addresses in it. I wanted to be able to click on the email address to send
an email.
first use a regular label with Content set to HTML.
then set an event in the before show:
Dim myemail
myemail = agents.email.Value
agents.email.Value = "<a href=mailto:" & myemail & ">" & myemail & "</a>"
agents is the form name
email is the label name
this will work for links to web sites too.
GAD
"Andrea Grub" <a.grub@qwirt.ch> wrote in message
news:assa8t$9bb$1@news.codecharge.com...
> Hi
>
> how can i make a database entry in a grid clickable? (Links to external
> Pages and/or Mailto actions)
>
> Thanks for your help
> Andrea
>
>
>
|
|
|
 |
RonB
|
| Posted: 12/10/2002, 3:39 AM |
|
Another option is to store the links in full html in the database to begin
with. This way all you have to do is set the field propperty to html and
thats it, no handcoding needed.
I store all my links in html in the database ie:
<a href="./somepage.php">Somepage</a>
RonB
"Andrea Grub" <a.grub@qwirt.ch> schreef in bericht
news:assa8t$9bb$1@news.codecharge.com...
> Hi
>
> how can i make a database entry in a grid clickable? (Links to external
> Pages and/or Mailto actions)
>
> Thanks for your help
> Andrea
>
>
>
|
|
|
 |
|