Professional Web Applications Themes

Postback after carriage return input - ASP.NET General

I have a WebForm with one control: A HTML INPUT control with the property "runat=server" set. If this page is running and I set the cursor in this control and enter "Carriage return", the page does a roundtrip (postback) to the server (which I doesn't want). If I include a second HTML INPUT control on this page, entering "Carriage return" does no postback. How can I prevent a postback, if the user enters "CR"? Thanks for an answer. Ferdi...

  1. #1

    Default Postback after carriage return input

    I have a WebForm with one control: A HTML INPUT control
    with the property "runat=server" set. If this page is
    running and I set the cursor in this control and
    enter "Carriage return", the page does a roundtrip
    (postback) to the server (which I doesn't want). If I
    include a second HTML INPUT control on this page,
    entering "Carriage return" does no postback.

    How can I prevent a postback, if the user enters "CR"?

    Thanks for an answer.

    Ferdi
    Ferdi Guest

  2. #2

    Default Re: Postback after carriage return input

    "Ferdi" <ch> wrote in message news:<0a2701c36638$6e9caff0$gbl>... 

    You shouldn't stop this functionality, because it is common
    functionality in web browsers, users expect this behavior.

    You can however stop it by doing <input type="text" onkeydown="return
    event.keyCode==13">
    Giscard Guest

  3. #3

    Default Re: Postback after carriage return input

    > You shouldn't stop this functionality, because it is common 

    It may be a common functionality in web browsers, but it can play havoc with
    an ASP.Net WebForm. It is important to anticipate and handle this event.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    Neither a follower nor a lender be.

    "Giscard" <com> wrote in message
    news:google.com... 
    news:<0a2701c36638$6e9caff0$gbl>... 
    >
    > You shouldn't stop this functionality, because it is common
    > functionality in web browsers, users expect this behavior.
    >
    > You can however stop it by doing <input type="text" onkeydown="return
    > event.keyCode==13">[/ref]


    Kevin Guest

  4. #4

    Default Re: Postback after carriage return input

     [/ref]
    common [/ref]
    behavior. 
    can play havoc with 
    handle this event.

    In reality my WebForm needs, in addition to a few
    listboxes and textboxes, several buttons to execute
    different functions on the server. The return key will do
    a click event on the first button (what ever the first
    button is), but this is not what the user wanted to do.
    The only solution to overcome this problem is to use HTML-
    buttons instead of Server-buttons. Is there a better
    solution for that problem?

    Ferdi 
    >news:<0a2701c36638$6e9caff0$gbl>... [/ref][/ref]
    control [/ref][/ref]
    enters "CR"? 
    >>
    >> You shouldn't stop this functionality, because it is[/ref][/ref]
    common [/ref]
    behavior. [/ref]
    onkeydown="return 
    >
    >
    >.
    >[/ref]
    Ferdi Guest

  5. #5

    Default Re: Postback after carriage return input

    Hi Ferdi,

    Based on my research and experience, I do not think that there is a better
    solution.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    <MCSD>
    Get Secure! C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.

    Jacob Guest

  6. #6

    Default Re: Postback after carriage return input

    Hi Ferdi,

    I have another simple idea for your reference. That is disable the
    onkeydown event of this button. The following is the code snippet:

    <INPUT id="Button2" style="Z-INDEX: 102; LEFT: 248px; WIDTH: 88px;
    POSITION: absolute; TOP: 96px; HEIGHT: 24px"
    type="button" value="HTML Control" name="Button2" runat="server"
    onkeydown="return false"></FONT>

    Does it answer your question? If I have misunderstood your concern, please
    let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    <MCSD>
    Get Secure! C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.

    Jacob Guest

Similar Threads

  1. Carriage Return
    By Barnabas (Barney) Yohannes in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: March 4th, 08:12 PM
  2. lingo carriage return
    By blkli0n webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 3
    Last Post: October 13th, 10:05 PM
  3. return Carriage access 97
    By AkEEmOdO in forum Microsoft Access
    Replies: 0
    Last Post: July 28th, 03:31 PM
  4. outputting a carriage return
    By Bob pilly in forum PHP Programming
    Replies: 2
    Last Post: July 17th, 03:29 PM
  5. Carriage return in .ini files
    By Doug Wilson in forum Macromedia Director Lingo
    Replies: 0
    Last Post: July 14th, 08:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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