Prevent pasting html page from clipboard into textbox in C # ASP

I have a simple web user input form using C #. Users copy what they are thin is the error screenshot to submit as form input. The copy action actually grabs the HTML of the error page. When this is inserted into my test field, I get an error (a potentially dangerous Request.Form value was found on the client (tbxComment). What is the best way to prevent this?

0


a source to share


2 answers


In Internet Explorer, Safari and FireFox 3, you can handle an event onbeforepaste

for an input control.

onbeforepaste Event from MSDN



You will need to examine the clipboard object and decide whether to allow pasting or not.

This is not an official (!) W3 standard event, but FF and Safari have included support for it.

+2


a source


I am using http://tinymce.moxiecode.com/ then hide all toolbars and configure tinymce to just use a few html tags.



Or you can strip html tags with regex in keyUp event because onChange event is not fired in TextAreas.

0


a source







All Articles