473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

why use htmlencode

Hi

I have a website where people can enter comments into a textarea - some of
these may have a bit of html - like links - or <blockquote>

the comments are stored in a Access2000 mdb file - A friend told me that i
have to use htmlencode on the textarea string before storing it in the
database. but it seems to work fine without doing this - is there any reason
as to why i should put it thru htmlencode?

when the comments are displayed they are written straight into a <div>

<div><%=recset.fields("comments")%></div>

thanks in advance

Diablo

Jul 22 '05 #1
4 4184
No, IMHO you should use HTMLEncode when placing it INTO the textarea (e.g.
for edit) and when displaying if you don't want any of the HTML to actually
render as intended. Again, IMHO, it should be stored as entered, and only
converted when displaying. I'd be curious about your friend's reason(s)
about having to store it in HTMLEncoded format.


"diablo" <di****@noplace.com> wrote in message
news:cG*****************@newsfe2-gui.ntli.net...
Hi

I have a website where people can enter comments into a textarea - some of
these may have a bit of html - like links - or <blockquote>

the comments are stored in a Access2000 mdb file - A friend told me that i
have to use htmlencode on the textarea string before storing it in the
database. but it seems to work fine without doing this - is there any
reason
as to why i should put it thru htmlencode?

when the comments are displayed they are written straight into a <div>

<div><%=recset.fields("comments")%></div>

thanks in advance

Diablo

Jul 22 '05 #2
when displaying if you don't want any of the HTML to actually
render as intended. Again, IMHO, it should be stored as entered,
I am a simple soul and may have misinterpreted my friends advice - but what
you are saying is that, ignoring the case of editing, I do not need to use
htmlencode?

I found this tip

http://www.devx.com/tips/Tip/13459

but i guess i can ignore it since if i store raw html in the db then i wont
have

&amp;

type characters in my DB.

Is my thinking correct?

and only
converted when displaying.


Here you mean displaying for editing not for rendering dont you?

TIA

D

Jul 22 '05 #3
> if i store raw html in the db then i wont have

&amp;

type characters in my DB.


Correct. It will just be &
and only
converted when displaying.


Here you mean displaying for editing not for rendering dont you?


No, I meant what I said. You trimmed some of it, but it *needs* to be
converted before being inserted into a textarea for editing. How you want
to handle rendering is up to you.

Do you want <a href=foo>link</a> to look exactly as it does in this message?
Then HTMLEncode it.

Do you want <a href=foo>link</a> to work as an active link when rendered?
Then do not HTMLEncode it.
Jul 22 '05 #4
No, I meant what I said. You trimmed some of it, but it *needs* to be
converted before being inserted into a textarea for editing. How you want
to handle rendering is up to you.

Do you want <a href=foo>link</a> to look exactly as it does in this message? Then HTMLEncode it.

Do you want <a href=foo>link</a> to work as an active link when rendered?
Then do not HTMLEncode it.

Ah... penny has dropped.

Thanks for your help

D
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: abcd | last post by:
Simple but not working at this moment I have to fill the HTML select control.... my values could be for example "test number 1" sample code, dim x Data = "test ...
4
by: Anders Both | last post by:
Hello dotnet.aspnet group - I want to do encode e.g. japanise or arabic text into something like: بةكوردي عةلي Before putting it in my HTML code (aspx page) . But when i try to use ...
3
by: Michael Gaillez | last post by:
Hi, I'm dynamically loading an assembly into an ASP.NET application. In the control that I load from that dynamic assembly I've tried to use Server.HTMLEncode but this results in a serious...
4
by: Andy Fish | last post by:
When using databinding, I have gotten into the habit of using single quotes (apostrophe) round attribute values rather than double quotes because this allows visual studio to work when there are...
3
by: David Lozzi | last post by:
Howdy, I have my left navigation of Hyperlinks, and part of the link's querystring is the title of the page they are going to. For example, one of the pages is Cars & Trucks. With HtmlEncode, it...
0
by: \A_Michigan_User\ | last post by:
I guess I'm not understanding this correctly. I have to set "ValidateRequest=False" for my asp.net 1.1 page that has a TextBox... so that I can avoid an error... if some user enters some html or...
1
by: Marco Miltenburg | last post by:
While working on some multilingual code I found a rather strange thing happening with Server.HTMLEncode. While loading different languages I change the Codepage and Charset in ASP to reflect the...
1
by: Alexander Higgins | last post by:
>>Thanks for the response.... Point Taken but this is not the case. Thus, if a person writes a text file on her or his computer and does not use UNICODE to save it, the current code page is...
7
by: jaja | last post by:
Hello all, I am familiar with the HtmlEncode Server method. I also read this : http://msdn2.microsoft.com/en-us/library/a2a4yykt(VS.80).aspx My question is: If I want to encode all inputs from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.