1


Is it possible to send a html text entered in asp.net text box without making validaterequest to false.
Thanks,
Amit Shah

1
  • Have you tried using Server.HTMLEncode() on the contents of the textbox? Commented Jul 24, 2010 at 16:26

2 Answers 2

2

You could probably add some javascript to encode the textbox value before the form is submitted.

something like:

$(function() {
  $("form").submit(function() {
    var myTextBox = $("#myTextBox");
    myTextBox.val( encodeMyHtml( myTextBox.val() ) );
  });
});

function encodeMyHtml(encodedHtml) {
  encodedHtml = escape(encodedHtml);
  encodedHtml = encodedHtml.replace(/\//g,"%2F");
  encodedHtml = encodedHtml.replace(/\?/g,"%3F");
  encodedHtml = encodedHtml.replace(/=/g,"%3D");
  encodedHtml = encodedHtml.replace(/&/g,"%26");
  encodedHtml = encodedHtml.replace(/@/g,"%40");
  encodeHtml.htmlEncoded.value = encodedHtml;
} 
Sign up to request clarification or add additional context in comments.

1 Comment

I should add that the user will probably see the value of the textbox change into the encoded value while the form is submitting.
0

Control.ValidateRequestMode, new to .NET 4.5, might be of interest to you. It allows you to specify how individual controls are validated.

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.