Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Enable/Disable LinkButton in Javascript

Enable/Disable LinkButton in Javascript

Scheduled Pinned Locked Moved C#
javascript
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SatyaKeerthi15
    wrote on last edited by
    #1

    I want to disable a LinkButton click on the client site. if(true) objLinkButton.disabled = true; else objLinkButton.disabled = false; This disables the link but I am still able to click on the link and do PostBack. Is there any way I can disable/enable the link.

    P 1 Reply Last reply
    0
    • S SatyaKeerthi15

      I want to disable a LinkButton click on the client site. if(true) objLinkButton.disabled = true; else objLinkButton.disabled = false; This disables the link but I am still able to click on the link and do PostBack. Is there any way I can disable/enable the link.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You also need to remove/add the href for the link depending on what you want to do.

      I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Onyx

      S 1 Reply Last reply
      0
      • P Pete OHanlon

        You also need to remove/add the href for the link depending on what you want to do.

        I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

        Forgive your enemies - it messes with their heads

        My blog | My articles | MoXAML PowerToys | Onyx

        S Offline
        S Offline
        SatyaKeerthi15
        wrote on last edited by
        #3

        Yes I tried it like below, document.getElementById(lkbtn).removeAttribute("href"); This works fine. But when i am adding attribute it raises error. document.getElementById(lkbtnEditMap).addAttribute("href"); So i did like this document.getElementById(lkbtnEditMap).setAttribute("href"); enable/disable works fine but when click on link button it showing error like resource cannot be found....

        P 1 Reply Last reply
        0
        • S SatyaKeerthi15

          Yes I tried it like below, document.getElementById(lkbtn).removeAttribute("href"); This works fine. But when i am adding attribute it raises error. document.getElementById(lkbtnEditMap).addAttribute("href"); So i did like this document.getElementById(lkbtnEditMap).setAttribute("href"); enable/disable works fine but when click on link button it showing error like resource cannot be found....

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          SatyaKeerthi15 wrote:

          document.getElementById(lkbtnEditMap).setAttribute("href");

          What are you setting the link to? You haven't actually specified the href value in there.

          I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

          Forgive your enemies - it messes with their heads

          My blog | My articles | MoXAML PowerToys | Onyx

          S 1 Reply Last reply
          0
          • P Pete OHanlon

            SatyaKeerthi15 wrote:

            document.getElementById(lkbtnEditMap).setAttribute("href");

            What are you setting the link to? You haven't actually specified the href value in there.

            I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

            Forgive your enemies - it messes with their heads

            My blog | My articles | MoXAML PowerToys | Onyx

            S Offline
            S Offline
            SatyaKeerthi15
            wrote on last edited by
            #5

            If Set href and click on link button again its loading page. Is it the good way to load page agian when click on linkbutton in same page.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups