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. Web Development
  3. ASP.NET
  4. How can I find which button was clicked?

How can I find which button was clicked?

Scheduled Pinned Locked Moved ASP.NET
questioncsharpjavascriptasp-net
5 Posts 4 Posters 0 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.
  • M Offline
    M Offline
    Martin_
    wrote on last edited by
    #1

    Hi experts. I just started programming in asp.net. Here is one task that I am having problems with. On a asp.net page there are 2 buttons(edit and save). I want to validate 2 fields only when the save button is clicked. If edit is clicked, then I don’t want to validate any fields. I thought that using javascript I can identify which button was clicked. Something like this: function Form1_onSubmit() { if(button clicked is btn save){ validate(); } else return true; } Thank you.

    G K V 3 Replies Last reply
    0
    • M Martin_

      Hi experts. I just started programming in asp.net. Here is one task that I am having problems with. On a asp.net page there are 2 buttons(edit and save). I want to validate 2 fields only when the save button is clicked. If edit is clicked, then I don’t want to validate any fields. I thought that using javascript I can identify which button was clicked. Something like this: function Form1_onSubmit() { if(button clicked is btn save){ validate(); } else return true; } Thank you.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      No, you can't. Use the onclick event of each button to catch which one is clicked.

      --- single minded; short sighted; long gone;

      1 Reply Last reply
      0
      • M Martin_

        Hi experts. I just started programming in asp.net. Here is one task that I am having problems with. On a asp.net page there are 2 buttons(edit and save). I want to validate 2 fields only when the save button is clicked. If edit is clicked, then I don’t want to validate any fields. I thought that using javascript I can identify which button was clicked. Something like this: function Form1_onSubmit() { if(button clicked is btn save){ validate(); } else return true; } Thank you.

        K Offline
        K Offline
        kubben
        wrote on last edited by
        #3

        Mark the edit button as CausesValidation = false, then use validator controls. Should work fine. Ben

        1 Reply Last reply
        0
        • M Martin_

          Hi experts. I just started programming in asp.net. Here is one task that I am having problems with. On a asp.net page there are 2 buttons(edit and save). I want to validate 2 fields only when the save button is clicked. If edit is clicked, then I don’t want to validate any fields. I thought that using javascript I can identify which button was clicked. Something like this: function Form1_onSubmit() { if(button clicked is btn save){ validate(); } else return true; } Thank you.

          V Offline
          V Offline
          Vasudevan Deepak Kumar
          wrote on last edited by
          #4

          You can actually pass this. And within the function you can inspect the sender's Value attribute.

          Vasudevan Deepak Kumar Personal Homepage Tech Gossips

          M 1 Reply Last reply
          0
          • V Vasudevan Deepak Kumar

            You can actually pass this. And within the function you can inspect the sender's Value attribute.

            Vasudevan Deepak Kumar Personal Homepage Tech Gossips

            M Offline
            M Offline
            Martin_
            wrote on last edited by
            #5

            Thank you experts

            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