Make button "default"

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Make button "default"

    Does anyone have some sample script to "press" a button or image button when
    the user presses the Enter key? I see this behavior on a lot of web pages
    but I'm not finding any samples.

    Thx

    --
    Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
    [email]paul@createsolutions.net[/email]



    Paul Turley Guest

  2. Similar Questions and Discussions

    1. Zoom tool is "-" instead of "+" as default how can I change
      When I select the zoom tool, instead of a + zoom, I get a - zoom. I have to hold down the alt key to get magnification. I don't understand how it got...
    2. #33400 [Opn->Csd]: make "make" a dendency of "make test"
      ID: 33400 Updated by: tony2001@php.net Reported By: nohn@php.net -Status: Open +Status: Closed Bug...
    3. DateField - Can u make the field default to "undefined"
      Hello, I am finding that if I put a DateField on a page, and the user does not select a date, when I get the date from the control using the...
    4. "make Makefile.PL" returns "...up to date"; make returns "no target to make"
      I'm attempting to install a perl module (AppConfig-1.56) on a FreeBSD 4.9 system. It has both perl 5.5.3 and 5.8.3 and several modules are already...
    5. How to make the "search text" feature work with non "txt" file
      On Fri, 27 Jun 2003 07:19:23 -0700, "Juergen" <anhorn@bktel.com> wrote: See MVP Doug Knox' comments and fix here:...
  3. #2

    Default Re: Make button "default"

    "Paul Turley" <paul@createsolutions.net> wrote in message
    news:OdwPQF6ODHA.2052@TK2MSFTNGP11.phx.gbl...
    > Does anyone have some sample script to "press" a button or image button
    when
    > the user presses the Enter key? I see this behavior on a lot of web pages
    > but I'm not finding any samples.
    >
    > Thx
    >
    > --
    > Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
    > [email]paul@createsolutions.net[/email]
    Just use the HTML tag <input type="submit" value="click here or press
    enter">

    --

    Jos Branders


    Jos Branders Guest

  4. #3

    Default RE: Make button "default"

    Hi Paul,

    In case you have multiple buttons on a webform, you could try this method.

    When a webform contains multiple buttons, the first one rendered will be
    fired when you press the Enter button. However, we can workaround this
    problem using the
    following method:

    1. Add the following script code to the <head> section of the aspx page.

    <SCRIPT LANGUAGE="javascript">
    function testEnterKey()
    {
    if (event.keyCode == 13)
    {
    event.cancelBubble = true;
    event.returnValue = false;
    Form1.Button2.click();
    }
    }
    </SCRIPT>

    2. In the code-behind page, add the onkeypress event handler to the
    attributes collectioins of the TextBox(es) on the page:

    private void Page_Load(object sender, System.EventArgs e)
    {
    //other initialization code

    TextBox1.Attributes.Add("onkeypress", "testEnterKey();");
    TextBox2.Attributes.Add("onkeypress", "testEnterKey();");
    ......
    }

    More information:

    HOWTO: Prevent Form Submission When User Presses the ENTER Key on a Form
    (Q298498)
    [url]http://support.microsoft.com/support/kb/articles/Q298/4/98.ASP[/url]

    returnValue Property
    [url]http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/returnv[/url]
    alue_1.asp

    cancelBubble Property
    [url]http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/cancelb[/url]
    ubble.asp

    Regards,

    Felix Wu
    =============
    This posting is provided "AS IS" with no warranties, and confers no rights.



    --------------------
    | From: "Paul Turley" <paul@createsolutions.net>
    | Subject: Make button "default"
    | Date: Wed, 25 Jun 2003 22:08:00 -0700
    | Lines: 12
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.3790.0
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | Message-ID: <OdwPQF6ODHA.2052@TK2MSFTNGP11.phx.gbl>
    | Newsgroups:
    microsoft.public.dotnet.framework.aspnet.webcontro ls,microsoft.public.dotnet
    .framework.aspnet
    | NNTP-Posting-Host: ts46-03-qdr3731.porch.wa.charter.com 68.113.26.153
    | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
    | Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet:155003
    microsoft.public.dotnet.framework.aspnet.webcontro ls:12621
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Does anyone have some sample script to "press" a button or image button
    when
    | the user presses the Enter key? I see this behavior on a lot of web pages
    | but I'm not finding any samples.
    |
    | Thx
    |
    | --
    | Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
    | [email]paul@createsolutions.net[/email]
    |
    |
    |
    |

    Felix Wu Guest

  5. #4

    Default Re: Make button "default"

    Set the "tab index" to 1
    "Jos Branders" <josnospambranders@fastmail.fm> wrote in message
    news:3efabc88$0$314$ba620e4c@reader0.news.skynet.b e...
    > "Paul Turley" <paul@createsolutions.net> wrote in message
    > news:OdwPQF6ODHA.2052@TK2MSFTNGP11.phx.gbl...
    > > Does anyone have some sample script to "press" a button or image button
    > when
    > > the user presses the Enter key? I see this behavior on a lot of web
    pages
    > > but I'm not finding any samples.
    > >
    > > Thx
    > >
    > > --
    > > Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
    > > [email]paul@createsolutions.net[/email]
    >
    > Just use the HTML tag <input type="submit" value="click here or press
    > enter">
    >
    > --
    >
    > Jos Branders
    >
    >

    Tim Boland Guest

  6. #5

    Default Re: Make button "default"

    I've tried this. I'm setting the tab index of my web server button to 1 and
    I've set it to the next index in sequence for all the controls. In either
    case, pressing Enter does nothing. This is on a web user control. I think
    I need to use client-side script to capture the Enter key press - unless I'm
    missing something.

    --
    Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
    [email]paul@createsolutions.net[/email]


    "Tim Boland" <bolandt@email.uc.edu> wrote in message
    news:OKgclmBPDHA.3016@TK2MSFTNGP10.phx.gbl...
    > Set the "tab index" to 1
    > "Jos Branders" <josnospambranders@fastmail.fm> wrote in message
    > news:3efabc88$0$314$ba620e4c@reader0.news.skynet.b e...
    > > "Paul Turley" <paul@createsolutions.net> wrote in message
    > > news:OdwPQF6ODHA.2052@TK2MSFTNGP11.phx.gbl...
    > > > Does anyone have some sample script to "press" a button or image
    button
    > > when
    > > > the user presses the Enter key? I see this behavior on a lot of web
    > pages
    > > > but I'm not finding any samples.
    > > >
    > > > Thx
    > > >
    > > > --
    > > > Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
    > > > [email]paul@createsolutions.net[/email]
    > >
    > > Just use the HTML tag <input type="submit" value="click here or press
    > > enter">
    > >
    > > --
    > >
    > > Jos Branders
    > >
    > >
    >
    >

    Paul Turley Guest

  7. #6

    Default Re: Make button "default"

    The web server button control renders these tags: <input type="submit"
    name="Login_Control1:btnLogin" ...

    I am calling server-side code on the click event so I need to use a web
    server button or image button.

    I've set the tab index to 0, 1 and other values. Any ideas?

    --
    Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
    [email]paul@createsolutions.net[/email]


    "Jos Branders" <josnospambranders@fastmail.fm> wrote in message
    news:3efabc88$0$314$ba620e4c@reader0.news.skynet.b e...
    > "Paul Turley" <paul@createsolutions.net> wrote in message
    > news:OdwPQF6ODHA.2052@TK2MSFTNGP11.phx.gbl...
    > > Does anyone have some sample script to "press" a button or image button
    > when
    > > the user presses the Enter key? I see this behavior on a lot of web
    pages
    > > but I'm not finding any samples.
    > >
    > > Thx
    > >
    > > --
    > > Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
    > > [email]paul@createsolutions.net[/email]
    >
    > Just use the HTML tag <input type="submit" value="click here or press
    > enter">
    >
    > --
    >
    > Jos Branders
    >
    >

    Paul Turley Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139