locked
Disable Linkbutton using javascript RRS feed

  • Question

  • Hi,

       I have requirement to disable or enable  linkbutton on click of checkbox(un checked event) by default , when page loads linkbutton  should be  disabled.

    Please let me know if any code snippet or solution for this. it should be done through javascript.

     

     

    Regards

    Pat 

    Tuesday, August 2, 2011 8:37 AM

Answers

  • This code might help you

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title></title>
      <script type="text/javascript">
        function validate() {
          var check = document.getElementById('cbEnable');
          if (!check.checked)
            document.getElementById('lnkEnable').disabled = true;
          else
            document.getElementById('lnkEnable').disabled = false;
        }
      </script>
    </head>
    <body>
      <form id="form1" runat="server">
      Enable/Diable Link Button :<input type="checkbox" onclick="validate()" id="cbEnable" />
      <asp:LinkButton ID="lnkEnable" Enabled="false" runat="server">Link Button</asp:LinkButton>
      </form>
    </body>
    </html>
    

     

    • Proposed as answer by Sankarsan Parida Wednesday, August 3, 2011 9:50 AM
    • Marked as answer by Cookie Luo Friday, August 5, 2011 2:29 AM
    Tuesday, August 2, 2011 10:46 AM