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 to get Focus on one Button,if two buttons exists on the same form

How to get Focus on one Button,if two buttons exists on the same form

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorial
4 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.
  • R Offline
    R Offline
    ravindradonkada
    wrote on last edited by
    #1

    Hi, I am Ravindra,presently doing a project in asp.net. The Login page of my Web Project consists of two Buttons. If user enters his username and password and clicks on enter button of keyboard, the Signin button is to be submitted not the other button. So,please specify how to get focus on the specified Button Thanks in advance. Ravindra

    S T V 3 Replies Last reply
    0
    • R ravindradonkada

      Hi, I am Ravindra,presently doing a project in asp.net. The Login page of my Web Project consists of two Buttons. If user enters his username and password and clicks on enter button of keyboard, the Signin button is to be submitted not the other button. So,please specify how to get focus on the specified Button Thanks in advance. Ravindra

      S Offline
      S Offline
      Sathesh Sakthivel
      wrote on last edited by
      #2

      Javascript can be used.

      With Regards Satips

      1 Reply Last reply
      0
      • R ravindradonkada

        Hi, I am Ravindra,presently doing a project in asp.net. The Login page of my Web Project consists of two Buttons. If user enters his username and password and clicks on enter button of keyboard, the Signin button is to be submitted not the other button. So,please specify how to get focus on the specified Button Thanks in advance. Ravindra

        T Offline
        T Offline
        ToddHileHoffer
        wrote on last edited by
        #3

        put the script below in your page. function ButtonPress (evt, btnID) { if (evt.keyCode == "13") {evt.returnValue= false ; evt.cancel= true ; document.getElementById(btnID).click(); return false; } } //the code behind should have this.txtPassword.Attributes.Add("onKeyPress", @"ButtonPress(event, '" + @this.ButtonSignin.ClientID + @"')"); //this code will cause the button click event when the user presses enter and the textbox has the focus. Basically you can set a default button for each textbox


        how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things --thedailywtf 3/21/06

        1 Reply Last reply
        0
        • R ravindradonkada

          Hi, I am Ravindra,presently doing a project in asp.net. The Login page of my Web Project consists of two Buttons. If user enters his username and password and clicks on enter button of keyboard, the Signin button is to be submitted not the other button. So,please specify how to get focus on the specified Button Thanks in advance. Ravindra

          V Offline
          V Offline
          vikram138
          wrote on last edited by
          #4

          Try using tabindex properties of the controls.. set tabindex to 1 for username 2 for password 3 for the button u want to click.. hope this will help u solve ur problem...

          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