Check Uncheck all CheckBoxes in an ASP.NET GridView kept in an Update Panel using jQuery

Users mailed back telling me that the example did not work in an UpdatePanel. I suspect the error they got was this:

“Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled”

The reason why this error occurs has been given very clearly over here

Here’s how to solve it:

1. Wrap the GridView and the Button in an Update Panel

2. Add a Literal control to the Page

<asp:Literal ID="lblResults" runat="server" Text=""></asp:Literal>

3. Instead of using Response.Write(), write the results to this Literal control