After switching to .net 4.0, some javascript code from a third party gridview crashes. It has got something to do with HtmlEncode and UrlEncode now encode single quotation marks
So before some code on the page was inserted like this:
DataItem.GetMember('Id').Value
and now its like this: DataItem.GetMember('Id').Value
The gridview does an eval
on that line, and crashes with a syntax error now. I can't change the javascript code in that gridview.
Is there anyway to solve this, without going backwards like this?
<pages controlRenderingCompatibilityVersion="3.5" />
EDIT: the pages controlRenderingCompatiblityVersion doesn't fix this also. Single quotes are still encoded.
From what I've read, it's a security feature and Microsoft is mum about changing it. The only work-around I've seen is you will need to create a custom encoder class. You can turn-off attribute encoding using this:
public class HtmlAttributeEncodingQuote : System.Web.Util.HttpEncoder
{
protected override void HtmlAttributeEncode(string value, System.IO.TextWriter output)
{
output.Write(value);
}
}
Then add this to web.config under system.web:
<httpRuntime encoderType="HtmlAttributeEncodingQuote"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With