Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Replace Suddenly doesn't work...

Reply
Thread Tools

Replace Suddenly doesn't work...

 
 
doar123@gmail.com
Guest
Posts: n/a
 
      01-22-2008
I'm operating a large web site, and I'm using a function replacing
double qoutes with & quot; in order to present text into a TEXTBOX.

From some unknown reason, the function does not work anymore.

Here it is:

function rQuote(zofim_rs)
if not IsNull(zofim_rs) and len(zofim_rs)>0 then
TempStr = zofim_rs
TempStr = Replace(TempStr, """", """,1,-1,1)
TempStr = Replace(TempStr, "'", "’",1,-1,1)
rQuote = TempStr
else rQuote = ""
end if
end function

does someone know what could be the reason that the function does not
work anymore ?

thanks,

Ilay
 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      01-22-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I'm operating a large web site, and I'm using a function replacing
> double qoutes with & quot; in order to present text into a TEXTBOX.
>
> From some unknown reason, the function does not work anymore.
>
> Here it is:
>
> function rQuote(zofim_rs)
> if not IsNull(zofim_rs) and len(zofim_rs)>0 then
> TempStr = zofim_rs
> TempStr = Replace(TempStr, """", """,1,-1,1)
> TempStr = Replace(TempStr, "'", "’",1,-1,1)
> rQuote = TempStr
> else rQuote = ""
> end if
> end function
>
> does someone know what could be the reason that the function does not
> work anymore ?


I assure you it still works. Whether it is doing what you think it
should be doing is another thing. The problem we have is we don't know
what is making you think it is not working. Error messages? Incorrect
results? If the latter, show us some inputs and show us the desired
results as well as the incorrect results.

Perhaps zofim_rs does not contain what you think it contains ...

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
 
 
 
doar123@gmail.com
Guest
Posts: n/a
 
      01-22-2008
there are no Errors. zofim_rs contains text.

I can see the text in the textbox, Until the double quotes.

Lets say the text is AA"BB
so I can see only AA.

If I print the text outside the textbox, I can see the whole string...

thanks,

Ilay

 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      01-22-2008

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm operating a large web site, and I'm using a function replacing
> double qoutes with & quot; in order to present text into a TEXTBOX.
>
> From some unknown reason, the function does not work anymore.
>
> Here it is:
>
> function rQuote(zofim_rs)
> if not IsNull(zofim_rs) and len(zofim_rs)>0 then
> TempStr = zofim_rs
> TempStr = Replace(TempStr, """", "&quot;",1,-1,1)
> TempStr = Replace(TempStr, "'", "&rsquo;",1,-1,1)
> rQuote = TempStr
> else rQuote = ""
> end if
> end function
>
> does someone know what could be the reason that the function does not
> work anymore ?
>


I would help if defined 'doesn' t work anymore'. Have put the function in
a little VBS and run a few test test string throught it? What is the
result?

Personally I prefer to use Server.HTMLEncode to do this sort of thing but
your code would work ok as well with the tweaks below:-

Function rQuote(zofim_rs)
If Len(zofim_rs) > 0 Then
rQuote = Replace(zofim_rs, """", "&quot;")
rQuote = Replace(rQuote , "'", "&apos;")
Else
rQuote = ""
End If
End Function

However the only bug I could actually see was &rsquo which is an entity I've
never head of. The DTD entity for an apostrophe is &apos;


--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      01-22-2008
(E-Mail Removed) wrote:
> I can see the text in the textbox, Until the double quotes.

^^^^^^^^^^^^^^

Learn to view source. The rest of your string ends up as attribute garbage.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      01-22-2008
(E-Mail Removed) wrote:
> there are no Errors. zofim_rs contains text.
>
> I can see the text in the textbox, Until the double quotes.
>
> Lets say the text is AA"BB
> so I can see only AA.
>
> If I print the text outside the textbox, I can see the whole string...
>
> thanks,
>

Assuming Anthony's tweak doesn't solve it for you, show us the code for
a small page that reproduces the problem. I'm not clear if that function
is being used in client-side or server-side code. So create a small test
page that does nothing but reproduce this problem - strip everything
else out of it. Post the code here.

To Anthony's point, why not use HTMLEncode?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
doar123@gmail.com
Guest
Posts: n/a
 
      01-22-2008
On 22 י*ואר, 18:31, "Anthony Jones" <(E-Mail Removed)> wrote:
> <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
>
>
> > I'm operating a large web site, and I'm using a function replacing
> > double qoutes with & quot; in order to present text into a TEXTBOX.

>
> > From some unknown reason, the function does not work anymore.

>
> > Here it is:

>
> > function rQuote(zofim_rs)
> > if not IsNull(zofim_rs) and len(zofim_rs)>0 then
> > TempStr = zofim_rs
> > TempStr = Replace(TempStr, """", "&quot;",1,-1,1)
> > TempStr = Replace(TempStr, "'", "&rsquo;",1,-1,1)
> > rQuote = TempStr
> > else rQuote = ""
> > end if
> > end function

>
> > does someone know what could be the reason that the function does not
> > work anymore ?

>
> I would help if defined 'doesn' t work anymore'. * Have put the function in
> a little VBS and run a few test test string throught it? *What is the
> result?
>
> Personally I prefer to use Server.HTMLEncode to do this sort of thing but
> your code would work ok as well with the tweaks below:-
>
> Function rQuote(zofim_rs)
> * * If Len(zofim_rs) > 0 Then
> * * * * rQuote = Replace(zofim_rs, """", "&quot;")
> * * * * rQuote = Replace(rQuote , "'", "&apos;")
> * * Else
> * * * * rQuote = ""
> * * End If
> End Function
>
> However the only bug I could actually see was &rsquo which is an entity I've
> never head of. *The DTD entity for an apostrophe is &apos;
>
> --
> Anthony Jones - MVP ASP/ASP.NET-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-


Thanks Anthony.

I don't know how to run a little VBS file...

"Doesn't work anymore" means that I used to see in the textbox the
whole string (AA"BB), and suddenly I can see only part of it (AA).
some more Information: about 2 weeks ago, We have formated the server.
There was NO change at the application, the files where Uploaded right
back.
Could the format effect the function somehow ?

another thing: I did another try, changing the function name to
rQuote111 and the problem was solve, I can see the whole string as
desired...
replacing the function on the entire website means 712 Replaces....

Does it make Sence ???

thanks

Ilay
 
Reply With Quote
 
doar123@gmail.com
Guest
Posts: n/a
 
      01-22-2008
On 22 י*ואר, 18:56, (E-Mail Removed) wrote:
> On 22 י*ואר, 18:31, "Anthony Jones" <(E-Mail Removed)> wrote:
>
>
>
>
>
> > <(E-Mail Removed)> wrote in message

>
> >news:(E-Mail Removed)...

>
> > > I'm operating a large web site, and I'm using a function replacing
> > > double qoutes with & quot; in order to present text into a TEXTBOX.

>
> > > From some unknown reason, the function does not work anymore.

>
> > > Here it is:

>
> > > function rQuote(zofim_rs)
> > > if not IsNull(zofim_rs) and len(zofim_rs)>0 then
> > > TempStr = zofim_rs
> > > TempStr = Replace(TempStr, """", "&quot;",1,-1,1)
> > > TempStr = Replace(TempStr, "'", "&rsquo;",1,-1,1)
> > > rQuote = TempStr
> > > else rQuote = ""
> > > end if
> > > end function

>
> > > does someone know what could be the reason that the function does not
> > > work anymore ?

>
> > I would help if defined 'doesn' t work anymore'. * Have put the function in
> > a little VBS and run a few test test string throught it? *What is the
> > result?

>
> > Personally I prefer to use Server.HTMLEncode to do this sort of thing but
> > your code would work ok as well with the tweaks below:-

>
> > Function rQuote(zofim_rs)
> > * * If Len(zofim_rs) > 0 Then
> > * * * * rQuote = Replace(zofim_rs, """", "&quot;")
> > * * * * rQuote = Replace(rQuote , "'", "&apos;")
> > * * Else
> > * * * * rQuote = ""
> > * * End If
> > End Function

>
> > However the only bug I could actually see was &rsquo which is an entity I've
> > never head of. *The DTD entity for an apostrophe is &apos;

>
> > --
> > Anthony Jones - MVP ASP/ASP.NET-הסתר טקסט מצוטט-

>
> > -הראה טקסט מצוטט-

>
> Thanks Anthony.
>
> I don't know how to run a little VBS file...
>
> "Doesn't work anymore" means that I used to see in the textbox the
> whole string (AA"BB), and suddenly I can see only part of it (AA).
> some more Information: about 2 weeks ago, We have formated the server.
> There was NO change at the application, the files where Uploaded right
> back.
> Could the format effect the function somehow ?
>
> another thing: I did another try, changing the function name to
> rQuote111 and the problem was solve, I can see the whole string as
> desired...
> replacing the function on the entire website means 712 Replaces....
>
> Does it make Sence ???
>
> thanks
>
> Ilay-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-


Dear Bob,

Here is the code of the page you can find here: http://www.zofim.org.il/test.asp

==================================================


<%@Language=VBScript Codepage="1255"%>

<%Function rQuote(zofim_rs)
If Len(zofim_rs) > 0 Then
rQuote=server.htmlencode(zofim_rs)
Else
rQuote = ""
End If
End Function

sql="select * from tbl where id=14809"
rs.Open sql, DB,0,1
%>
<input type="text" name="test" value="<%=rQuote(rs("name"))%>">

==================================================

For some reason it DOES work on this page, but not on other
pages..........


Ilay
 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      01-22-2008
(E-Mail Removed) wrote:
> Dear Bob,
>
> Here is the code of the page you can find here:
> http://www.zofim.org.il/test.asp
>
> ==================================================
>
>
> <%@Language=VBScript Codepage="1255"%>
>
> <%Function rQuote(zofim_rs)
> If Len(zofim_rs) > 0 Then
> rQuote=server.htmlencode(zofim_rs)


Oh! You've switched to using htmlencode!

> Else
> rQuote = ""
> End If
> End Function
>
> sql="select * from tbl where id=14809"
> rs.Open sql, DB,0,1
> %>
> <input type="text" name="test" value="<%=rQuote(rs("name"))%>">
>
> ==================================================
>
> For some reason it DOES work on this page, but not on other
> pages..........


Well, obviously something is different on those pages, but we have no
way of knowing what.

We have no access to your database, so the sql stuff is irrelevant.
Let's hard-code a test string:

<%@Language=VBScript Codepage="1255"%>

<%Function rQuote(zofim_rs)
If Len(zofim_rs) > 0 Then
rQuote=server.htmlencode(zofim_rs)
Else
rQuote = ""
End If
End Function

%>
<input type="text" name="test" value="<%=rQuote("test AA""BB end
test")%>">

It certainly seems to work correctly for me.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
doar123@gmail.com
Guest
Posts: n/a
 
      01-22-2008
On 22 י*ואר, 20:20, "Bob Barrows [MVP]" <(E-Mail Removed)>
wrote:
> (E-Mail Removed) wrote:
> > Dear Bob,

>
> > Here is the code of *the page you can find here:
> >http://www.zofim.org.il/test.asp

>
> > ==================================================

>
> > <%@Language=VBScript Codepage="1255"%>

>
> > <%Function rQuote(zofim_rs)
> > * * If Len(zofim_rs) > 0 Then
> > rQuote=server.htmlencode(zofim_rs)

>
> Oh! You've switched to using htmlencode!
>
> > * * Else
> > * * * * rQuote = ""
> > * * End If
> > End Function

>
> > sql="select * from tbl where id=14809"
> > rs.Open sql, DB,0,1
> > %>
> > <input type="text" name="test" value="<%=rQuote(rs("name"))%>">

>
> > ==================================================

>
> > For some reason it DOES work on this page, but not on other
> > pages..........

>
> Well, obviously something is different on those pages, but we have no
> way of knowing what.
>
> We have no access to your database, so the sql stuff is irrelevant.
> Let's hard-code a test string:
>
> <%@Language=VBScript Codepage="1255"%>
>
> <%Function rQuote(zofim_rs)
> * * If Len(zofim_rs) > 0 Then
> rQuote=server.htmlencode(zofim_rs)
> * * Else
> * * * * rQuote = ""
> * * End If
> End Function
>
> %>
> <input type="text" name="test" value="<%=rQuote("test AA""BB end
> test")%>">
>
> It certainly seems to work correctly for me.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.


Well, I don't know what to say. I'm perplexed.

All I know is that:

1. it worked just fine 2 weeks ago (on hundreds of pages...). beside
formating the server - nothing happened.
2. If I produce a new page, it works, on the older ones - it doesn't.
3. If I use the SAME function, just replacing her name (rQuote >
rQuote111) - It works fine.

thank you for your help. If someone has an creative Idea, please let
me know....

Ilay
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace /n with a XHTML <br /> using string.replace Alun ASP .Net 3 02-18-2008 05:52 AM
Re: [Pyrex] pyrex functions to replace a method (Re: replace a method Greg Ewing Python 2 06-29-2006 05:25 PM
pyrex functions to replace a method (Re: replace a method in class:how?) Brian Blais Python 1 06-27-2006 12:13 PM
s/$match/$replace/ fails when $replace has backreferences anonyusenet@yahoo.com Perl Misc 3 09-12-2005 11:03 AM
help with string replace - for doing selective replace Prasad S Javascript 2 08-27-2004 03:22 PM



Advertisments