Solved

retaining html input in textbox...

Posted on 2004-08-07
3
375 Views
Last Modified: 2012-06-27
using a textarea in a form to capture user text entry that includes html code... when storing the text, the greater-than and less-than symbols are being replaced with their & equivalent codes. i tried server.htmlencode and htmldecode and not fixing it.

any ideas?
0
Comment
Question by:loyaliser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
AerosSaga earned 250 total points
ID: 11744365
This is because the embeded html code could countain a malicious script to attempt to compromise your system.  ASP.NET recognizes this, the only way to leave the html intact is to disable validation for the whole page in the page directive.

Regards,

Aeros
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11744368
If you still want to turn off validation to retain the html see here for example:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconpage.asp

Regards,

Aeros
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11744510
here's a good article describing your options http://asp.net/faq/RequestValidation.aspx ...

this is exactly what you want to do ...

<%@ Page ValidateRequest="FALSE" language="C#" %>

<script runat="server">

void EnterBtn_Click(Object Src, EventArgs E) {
Message.Text = "Hi " + HttpUtility.HtmlEncode(Name.Text) + ", welcome to ASP.NET!";
}

</script>
<html>
<body>
<form runat=server>
Please enter your name: <asp:textbox id="Name" runat=server/>
<asp:button text="Enter" Onclick="EnterBtn_Click" runat=server/><br>
<asp:label id="Message" runat=server/>
</form>
</body>
</html>
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question