0

When I use a HTML-element in my textboxes I was getting this error:

enter image description here

To fix this error, I did this:

  1. Adding ValidateRequest="false" at the top of the .aspx page.
  2. Adding <httpRuntime targetFramework="4.0" requestValidationMode="2.0" /> to the webconfig file.

After doing this, the error above didnt appear, and the HTML-elements that I used were shown with the markup.

For example: I used the <b>Test</b> elements in the textbox, and this was showed in a label as:

Test

But what I would like to have is, when someone adds HTML elements to my textbox, the error shouldn't appear, and the elements shouldn't be converted. So the label must show:

<b>Test</b> instead of Test (which is BOLD)

What can I do to make it like that?

1 Answer 1

1

Use Server.HtmlEncode("<b>Test</b>")

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.