Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
$('[id*=btnSearch]').on("click", function () {

            var sSearchTerm = "1045";
            var list = "";

            $("#<%=dgv_Report.ClientID%> tr:has(td)").each(function () {
                var cell = $(this).find("td:eq(1)").html();
                if (cell == sSearchTerm) {
                    $(this).parent().hide();
                    return true;
                }

            });
        });



When I use this code, Page get refreshed and it wont hide rows of GridView. So please let me know how to convert above code in c#
Posted
Comments
Raul Iloc 4-Sep-14 12:45pm    
Did you check my solution?
m-shraddha 11-Sep-14 2:10am    
yup

1 solution

1.The JavaScript code (including jQuery), is executed automatically on the client (internet browser) and this speed up the web application response to user actions.

2.The C# code in ASP.NET is executed on the server on the page request or postbacks. See details in the next link:
http://msdn.microsoft.com/en-us/library/vstudio/ms178472(v=vs.100).aspx[^]

3.The short answer is you cannot do the conversion from JavaScript into C# code and also make no sense to do such conversion. What you can do, if you need to extend your code for searching, is to use jQuery together with AJAX to call a search method implemented in C# code in your code behind. See details in the next article:
Using jQuery for AJAX in ASP.NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900