How to prevent postback on asp button while displaying a popup using JQuery

后端 未结 3 410
感情败类
感情败类 2021-01-27 06:27

I have the following ItemTemplate in my GridView:


    

        
3条回答
  •  渐次进展
    2021-01-27 06:41

    Actually you have not showed up the implementation of your method myfunction(), in case the myfunction() method have any syntactical error then the OnClientClick event will be void and it will post-back/submit the form to the server.

    Try to remove the call from OnClientClick and just implement your logic at jquery on click event by using class selector as follows

    $(document).ready(function () {
            $(".btnSearch").click(function (e) {
                e.preventDefault();
                alert($(this).val() + " Clicked"); // you can put your method mymethod() here 
                // you can put youe popup logic here
    
                return false; 
    
            });
        });
    

    You can also see this example of js fiddle

提交回复
热议问题