Author: franzo | Posted on: 5/4/2010 6:20:09 PM | Views : 479

.Net 4.0 is encoding values when using Attributes.Add. In previous versions it didn't. With the new behaviour it is no longer possible to write attributes containing single quotes.

Here's an example.

<asp:TextBox ID="txtTest" runat="server" />
txtTest.Attributes.Add("onkeyup", "keyuphandler('hello')");
With the application pool framework version set to 2.0 it produces the desired result:

<input name="txtTest" type="text" id="txtTest" onkeyup="keyuphandler('hello')" />

With it set to 4.0 it produces an undesirable result:
<input name="txtTest" type ...

Go to the complete details ...