469,266 Members | 2,014 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,266 developers. It's quick & easy.

Cannot build a string containing the < character

I'm facing a crazy problem:

<%
spc = "<abcd"
response.write spc
%>

will not work, spc is empty.
When I replace <abcd with ab<cd, then spc contains only ab.

Where do I make the mistake ?
Pierrot

Jan 13 '06 #1
3 1220
Basically you are not making any mistake. If you would view the source
code of the page generated you will see the < sign. However the browser
interprets the < with a html tag. If you want to show the < as text,
you can use &lt; definition.

So in your case:

spc = "&lt;abcd" which will render in the browser as <abcd
Giganews wrote:
I'm facing a crazy problem:

<%
spc = "<abcd"
response.write spc
%>

will not work, spc is empty.
When I replace <abcd with ab<cd, then spc contains only ab.

Where do I make the mistake ?
Pierrot


Jan 13 '06 #2
Server.HTMLEncode is another way of not having to worry about special
characters not shoping.

Response.Write Server.HTMLEncde(spc)

Ray at work

"Giganews" <ph@email.no> wrote in message
news:V8********************@giganews.com...
I'm facing a crazy problem:

<%
spc = "<abcd"
response.write spc
%>

will not work, spc is empty.
When I replace <abcd with ab<cd, then spc contains only ab.

Where do I make the mistake ?
Pierrot

Jan 13 '06 #3
No big deal but minor typo:
Response.Write Server.HTMLEncde(spc)

To be:
Response.Write Server.HTMLEncode(spc)

Best regards,
-Paul
www.Bullschmidt.com - Freelance Web and Database Developer
www.Bullschmidt.com/DevTip.asp - ASP Design Tips

Jan 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by higabe | last post: by
7 posts views Thread by tuchka | last post: by
5 posts views Thread by Minkoo Seo | last post: by
8 posts views Thread by gthorpe | last post: by
6 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.