|
 |
asp_databases thread: Re: Replace function
Message #1 by "Ken Schaefer" <ken@a...> on Fri, 5 Apr 2002 17:36:39 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Grant Davies" <webdev@i...>
Subject: [asp_databases] Replace function
: I have a search feature that searches the records and returns a trimed
: string.
:
: But of course it also sees the html tags as characters, which as you can
: imaging plays havoc if I get half a table tag or something.
:
: So I want to make a function to replace all of the html tags as they come
: out of the database.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Why write your own when there is one already built in to ASP?
Server.HTMLEncode()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Any ideas would be wonderful?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a question? Are you asking whether ideas are wonderful?
Cheers
Ken
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 9 Apr 2002 13:51:42 +1000
|
|
Oh,
You want to *strip* out the HTML characters?
http://www.4guysfromrolla.com/ASPScripts/PrintFAQ.asp?FAQID=155
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Grant Davies" <grant@w...>
Subject: [asp_databases] Re: Replace function
: Hi Ken,
:
: Seemed so simple... but this is what I get now:
:
<snip>
:
: I really want to get rid of the html tags.
:
: Is there a certain way I should use the server.HTMLEncode() function.
:
: This is how I use it now, with a little trim function...:
:
: <%
: Function trimLeft(text)
: If Len(text) > 300 Then
: trimLeft = Left(text,290) & "..."
: Else
: trimLeft = text
: End If
: End Function
: %>
:
: Then in a loop
:
: <%=trimLeft(server.HTMLEncode(rsksearch("pageText1")))%>
:
: This is the function I was trying to incorporate:
:
: <% Function htmlout(text)
: htmlout = replace(text, "<*>", "") ' where * would be a
: wildcard
: End Function
: %>
Message #3 by "Grant Davies" <grant@w...> on Sat, 6 Apr 2002 11:20:35 +1000
|
|
Hi Ken,
Seemed so simple... but this is what I get now:
------------------------------------------------------------------------
--------
Councillors
<TABLE cellSpacing=4 cellPadding=7 width="100%" border=0> <TBODY> <TR>
<TD vAlign=top width="48%"><FONT
color=#800000><B>Mayor</B></FONT><STRONG> <P align=justify><FONT
color=#000080>Councillor RE (R...
------------------------------------------------------------------------
--------
Council Chambers
<P>Pick of Council Chambers and some blurb. Pick of Council
Chambers and some blurb. Pick of Council Chambers and some
blurb. Pick of Council Chambers and some blurb. Pick of
Council Chambers and some blurb. Pick of Council Chambers and so...
------------------------------------------------------------------------
--------
Policies
<P>Council Policies goes here. Council Policies goes
here. Council Policies goes here. Council Policies goes
here. Council Policies goes here. Council Policies goes
here. Council Policies goes here. Council Policies goes ...
------------------------------------------------------------------------
--------
It still prints the html tags....
I really want to get rid of the html tags.
Is there a certain way I should use the server.HTMLEncode() function.
This is how I use it now, with a little trim function...:
<%
Function trimLeft(text)
If Len(text) > 300 Then
trimLeft = Left(text,290) & "..."
Else
trimLeft = text
End If
End Function
%>
Then in a loop
<%=trimLeft(server.HTMLEncode(rsksearch("pageText1")))%>
This is the function I was trying to incorporate:
<% Function htmlout(text)
htmlout = replace(text, "<*>", "") ' where * would be a
wildcard
End Function
%>
Kindest Regards
Grant
****************
-----Original Message-----
From: Ken Schaefer [mailto:ken@a...]
Sent: Friday, 5 April 2002 5:37 PM
To: ASP Databases
Subject: [asp_databases] Re: Replace function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Grant Davies" <webdev@i...>
Subject: [asp_databases] Replace function
: I have a search feature that searches the records and returns a trimed
: string.
:
: But of course it also sees the html tags as characters, which as you
can
: imaging plays havoc if I get half a table tag or something.
:
: So I want to make a function to replace all of the html tags as they
come
: out of the database.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Why write your own when there is one already built in to ASP?
Server.HTMLEncode()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Any ideas would be wonderful?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a question? Are you asking whether ideas are wonderful?
Cheers
Ken
Message #4 by "Grant Davies" <webdev@i...> on Fri, 5 Apr 2002 13:02:20 +1000
|
|
Hi all,
I have page content in a database..... this includes html tags.
I have a search feature that searches the records and returns a trimed
string.
But of course it also sees the html tags as characters, which as you can
imaging plays havoc if I get half a table tag or something.
So I want to make a function to replace all of the html tags as they come
out of the database.
This is what I am looking for but am stuck with the wildcard:
Function htmlout(text)
htmlout = replace(text, "<*>", "")
End Function
Any ideas would be wonderful?
Regards
Grant
|
|
 |