LinkButton does not invoke on click()

前端 未结 8 902
不思量自难忘°
不思量自难忘° 2020-12-29 08:15

Why doesn\'t this work?

    
    

        
8条回答
  •  礼貌的吻别
    2020-12-29 08:53

    you need to assign an event handler to fire for when the click event is raised

        $(document).ready(function() {
            $('.myButton', '#form1')
                .click(function() {  
                    /* 
                       Your code to run when Click event is raised.
                       In this case, something like window.location = "http://..."                      
                       This can be an anonymous or named function
                    */
                    return false; // This is required as you have set a PostbackUrl
                                  // on the LinkButton which will post the form
                                  // to the specified URL
                }); 
        });
    

    I have tested the above with ASP.NET 3.5 and it works as expected.

    There is also the OnClientClick attribute on the Linkbutton, which specifies client side script to run when the click event is raised.

    Can I ask what you are trying to achieve?

提交回复
热议问题