Tom
Tom

Reputation: 12998

convert html in a vb.net textbox

I have a textbox which I need to enter html code into (like < strong> or < em> for example).

The trouble is this is causing an error writing this back to the database.

A potentially dangerous Request.Form value was detected from the client (tbVOther="< strong>test

Is there a way around this without turning off the request validation setting?

Upvotes: 1

Views: 1050

Answers (3)

Peter
Peter

Reputation: 9712

At the top of your page you'll need to set the following property:

 <%@ Page ValidateRequest="false" etc.... %>

Validate Request will make sure that these values can be posted back to the server. But keep in mind that there are reasons why this is set to true by defailt and you should be careful to make sure people can't submit javascript functions/calls, etc... through your editor.

Upvotes: 1

David M&#229;rtensson
David M&#229;rtensson

Reputation: 7620

There is a server setting to prevent posting of HTML that need to be switched of for this to work, I do not remebre where though.

Just make sure that you do correct sanitisation on your own before admitting to the database ;)

Upvotes: 0

Dean
Dean

Reputation: 5946

It might be easier sanitising the input via Javascript replacing the offending characters with safe ones i.e replacing <> with ^ instead

Upvotes: 1

Related Questions