Solved

retaining html input in textbox...

Posted on 2004-08-07
3
361 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now