I am developing a backend website using ASP.NET. I had a 3 GridView controls within the page. I am using the jQuery to add a CSS class to third column of the 3 GridViews when the page in ready as I tried to add this class by setting the CssClass property of the column and it did not work. The problem is that I used an UpdatePanel to ensure a partial post back, however, when I used such panel when the page post back the class of the third column I add through jQuery is lost and the column returned to its normal shape (i.e., normal CheckBox). I googled and I tried too many solution but none of them worked. I added the script again within the <contenttemplate> tag, I add the method name within the jQuery to the OnClientClick of the button that update the GridView content, I registered a script using the C# code within the Page_Load event

ClientScriptManager script = Page.ClientScript;
        script.RegisterClientScriptBlock(script.GetType(), "PostBack", "MyScript", true);

However, none of the three methods worked for me can anyone help. In addition I need to call a C# code from within script, however, too many people saying put the code within <%= and %> pair but when doing this and debugging I found that all of my code does not exist within the script block!!!!

2 Years
Discussion Span
Last Post by Amr.Mohammad87


I got the solution and it works for me. I put the Sys.WebForms.PageRequestManager.getInstance().add_endRequest with my script function as a parameter within my contenttemplate inside the update panel. However, it did not work for my first design so I had to change it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.