开发者

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('&amp;', 'g'), "&"); 
   // less-thans (<)
   result = result.replace(RegExp('&lt;', 'g'), "<");
   // greater-thans (>)
   result = result.replace(RegExp('&gt;', 'g'), ">");
   // Replace quotes if it isn't for display,
   result = result.replace(RegExp('&quot;', 'g'), '"');
   return result;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜