Reputation: 327
Is it possible to send a html text entered in asp.net text box without making validaterequest to false.
Thanks,
Amit Shah
Upvotes: 1
Views: 1320
Reputation: 9562
Control.ValidateRequestMode, new to .NET 4.5, might be of interest to you. It allows you to specify how individual controls are validated.
Upvotes: 0
Reputation: 5427
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;
}
Upvotes: 2