Allow Greater Than and Less Than in data bound columns
In my intranet application, I have a data bound database column that frequently contains greater than and less than characters. When the user tries to enter these values (such as "<D>"), IIS throws an "httprequestvalidationexception". Can someone tell me how I could disable th开发者_C百科is or encode the string to be safe? (Or both??)
Try setting ValidateRequest
to false
on your page.
we have used a simple function like this in the client before posting back for anything on the server.
function htmlDecode(source) {
var result = source;
// ampersands (&)
result = result.replace(RegExp('&', 'g'), "&");
// less-thans (<)
result = result.replace(RegExp('<', 'g'), "<");
// greater-thans (>)
result = result.replace(RegExp('>', 'g'), ">");
// Replace quotes if it isn't for display,
result = result.replace(RegExp('"', 'g'), '"');
return result;
}
精彩评论