how do I disable Button asp.net

后端 未结 4 2153
旧时难觅i
旧时难觅i 2021-02-12 10:57

How can I disable or enable button in asp.net? I want to disable button after click to prevent double click. I am trying to disable my Login button after clicking on it.

4条回答
  •  失恋的感觉
    2021-02-12 11:12

    write a java-script function which checks the user name and password.
    If they are not blank the disable the button.
    But if you disable the button and there is a postback. And after the postback still it will be enable.
    So Idea is

    1. Create a java-script function.
    2. validate user-name and password
    3. if they are valid
    4. disable the button (javascript).
    5. Add ClientIdMode="Static" to your to prevent .NET from mangling the name.

    --edit

    Your java-script code

    function btn_disable
    {
       //check for user name and password
       // if filled
       document.getElementById("btn").disabled=true;
    
    }
    

提交回复
热议问题