Jquery Asp.net button disable

前端 未结 6 676
时光说笑
时光说笑 2021-02-09 14:42

html code:


Jquery Code:

$(\'[id$=b         


        
6条回答
  •  无人共我
    2021-02-09 15:41

    It wouldn't work because the generated HTML id is different than the ASP.NET id.
    So btnTest will be rendered as another Id.

    A quick dirty way is to to run the page, view the HTML source and locate the button's generated Id and pass it as an arugment in the jQuery function.

    A better way is to generate the jQuery function through code behind:

    Literal1.Text = "$('[id$=" + btnTest.ClientId + "]').click(function(
    {$(this).attr('disabled', 'disabled');});";
    

    Edit: Also I couldn't help but realize that your OnClick attribute should point to btnTest_Click and not btn_Click

提交回复
热议问题