AutoPostBack question.

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

  1. #1

    Default AutoPostBack question.

    Hi,

    I'm having a straight HTML <input type="text"
    onkeypress="CheckKey();"> within a <form runat="server">.
    When I press ENTER when in the textbox, the client-side
    CheckKey() function is executed but still the form or page
    seems to do an AutoPostBack to the server.

    Any ideas on how to avoid this postback?
    Thanx a lot in advance,

    Domien
    Domien Holthof Guest

  2. Similar Questions and Discussions

    1. TabIndex and AutoPostBack
      I have a long form that includes several fields which require AutoPostBack=True. I want the user to be able to tab through the fields in sequence...
    2. no AutoPostBack for Grid?
      I have a grid with a select button. I went to turn off AutoPostBack and there is no such attribute. Is there any way to make a grid behave as...
    3. Problem with Autopostback
      I have a relatively long page with a number of webcontrols with "autopostback" set to true. The contents/items/datasources of the subsequent...
    4. AutoPostBack
      I have another question. On my page there is a datagrid and in a templatecolumn it contains a dropdownlist. The AutoPostBack property of the...
    5. Can NOt AutoPostBack for two DDL
      Can NOt AutoPostBack for two DDL Posted: 07-03-2003 01:35 AM I have a usercontrol a.ascx ,put two DDL on the ascx. in an aspx's codebehind...
  3. #2

    Default AutoPostBack question.

    Hi Domien

    Just use return; statement in your javascript function.

    HTH
    Ravikanth

    >-----Original Message-----
    >Hi,
    >
    >I'm having a straight HTML <input type="text"
    >onkeypress="CheckKey();"> within a <form
    runat="server">.
    >When I press ENTER when in the textbox, the client-side
    >CheckKey() function is executed but still the form or
    page
    >seems to do an AutoPostBack to the server.
    >
    >Any ideas on how to avoid this postback?
    >Thanx a lot in advance,
    >
    >Domien
    >.
    >
    Ravikanth[MVP] Guest

  4. #3

    Default Re: AutoPostBack question.

    The statement has to say "return false", and your onclick event has to say
    "return CheckKey();".


    Also, this is just a plain submit to the server, this is not related to the
    autopostback that can happen with a dropdown.

    "Domien Holthof" <domien.holthof@alcopa2wheels.com> wrote in message
    news:095601c34c65$9a70d6c0$a501280a@phx.gbl...
    > Hi Ravikanth,
    >
    > I didn't realy understood what you meant, so I tried to
    > make the function look like this:
    >
    > function CheckKey()
    > {
    > ... // My code to check the key and do stuff...
    > return;
    > }
    >
    > That didn't solve it. Next I tried this :
    > function CheckKey()
    > {
    > ... // My code to check the key and do stuff...
    > return false;
    > }
    >
    > That didn't do the trick either. But could anyone tell
    > WHAT is causing the postback and how to prevent it?
    >
    > Thanx,
    > Domien
    >
    > >-----Original Message-----
    > >Hi Domien
    > >
    > >Just use return; statement in your javascript function.
    > >
    > >HTH
    > >Ravikanth
    > >
    > >
    > >>-----Original Message-----
    > >>Hi,
    > >>
    > >>I'm having a straight HTML <input type="text"
    > >>onkeypress="CheckKey();"> within a <form
    > >runat="server">.
    > >>When I press ENTER when in the textbox, the client-side
    > >>CheckKey() function is executed but still the form or
    > >page
    > >>seems to do an AutoPostBack to the server.
    > >>
    > >>Any ideas on how to avoid this postback?
    > >>Thanx a lot in advance,
    > >>
    > >>Domien
    > >>.
    > >>
    > >.
    > >

    Marina 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