ASP.NET 2.0 - Enter Key - Default Submit Button

Rate It (5)

Last post 11-04-2009 2:36 AM by Babunareshnarra. 79 replies.

Sort Posts:

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    04-22-2009, 2:27 AM
    • Member
      12 point Member
    • chope_07
    • Member since 04-22-2009, 5:25 AM
    • Parañaque, Philippines
    • Posts 6
    Hi,

    Try using this, Assuming that we have asp TextBox with an ID of "TextBox1" and Button with an ID of "Button1" controls on our page.

    Put this code on the Head of your aspx page.

    <script language="javascript">
    function doClick(e, buttonid){
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);
    if (bt){
    if (evt.keyCode == 13){
    bt.click();
    return false;
    }
    }
    }
    </script>

    And this on page load event.
    TextBox1.Attributes.Add("onkeypress", "return doClick(event,'" + Button1.ClientID + "')");
    Developing Skills. Sharing Skills.
    http://www.stringlist.com
    Filed under:
  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    05-06-2009, 2:38 PM
    • Member
      291 point Member
    • Laplain
    • Member since 08-11-2005, 9:51 PM
    • Oregon
    • Posts 68

    Using a Panel's "DefaultButton" worked perfectly for my needs.  I have three text box functions on one page, and just made sure each "tool" had a Panel surrounding it, then added the button as the Default to each panel.  Thanks! Yes

    Jasee
    Filed under: ,
  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    10-22-2009, 3:41 PM
    • Participant
      1,052 point Participant
    • uswebpro
    • Member since 10-30-2003, 8:14 PM
    • Prague, CZ
    • Posts 219

    thanks Grant, this helped!

    I will use this on ALL my sites :)

    Cheers!
    - Aron
  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    11-03-2009, 11:09 PM
    • Member
      321 point Member
    • cnranasinghe
    • Member since 10-27-2009, 12:41 AM
    • Sri Lanka
    • Posts 85

    Easiest way to do this is to add a panel control and set the default button property of the panel control

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    11-04-2009, 2:36 AM
    • Participant
      886 point Participant
    • Babunareshnarra
    • Member since 07-12-2009, 3:10 AM
    • Hyderabad
    • Posts 179

    Check these out

    http://stackoverflow.com/questions/333141/asp-net-default-button

    http://www.velocityreviews.com/forums/t121858-how-do-i-use-the-defaultbutton-setting-when-using-master-pages.html

    Hope this helps.


    Regards

    Babu Naresh Narra

    Remember to click “Mark as Answer” on the post If you get answer from my post(s) !
Page 6 of 6 (80 items) « First ... < Previous 2 3 4 5 6