JS OnKeyPress causes button click

Discussion in 'ASP .Net' started by =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Aug 24, 2005.

  1. Hi

    I've got a form with a TextBox and an invisible button, and I've got it set
    so that pressing enter causes the button to click. WOrks fine, the forms
    submits on enter and my datalist refreshes (tis a search textbox/list).

    I'm trying to implement AJAX style behaviour (its an intranet) - so as you
    type in the box, it refreshes the results list.

    So far I've tried OnKeyPress="TextChange" - where TextChange is a public C#
    method in Codebehind, I've tried
    OnKeyPress="javascript:document.form1.submit()" and ive just tried
    OnKeyPress="__doPostBack(blah...)" - all with the same effect.

    The form submits itself, as you;d expect, but then when it returns,
    everything is reset to when the page was first loaded (eg. txtbox is set to
    "Type here" etc). It's like it's reloading the page from scratch, and
    ignoring ViewState. ViewState is switched on thouh.

    I don't know whats wrong - any suggestions on how to do this!?

    I should point out that the textbox and hidden imagebutton are in a user
    control - dunno if that makes any diff?

    Cheers



    Dan
     
    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Aug 24, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    Ferret Face Guest

    You might have to start messing with the PostBack method(s).

    What to the group gurus think?

    "dhnriverside" <> wrote in message
    news:...
    > Hi
    >
    > I've got a form with a TextBox and an invisible button, and I've got it
    > set
    > so that pressing enter causes the button to click. WOrks fine, the forms
    > submits on enter and my datalist refreshes (tis a search textbox/list).
    >
    > I'm trying to implement AJAX style behaviour (its an intranet) - so as you
    > type in the box, it refreshes the results list.
    >
    > So far I've tried OnKeyPress="TextChange" - where TextChange is a public
    > C#
    > method in Codebehind, I've tried
    > OnKeyPress="javascript:document.form1.submit()" and ive just tried
    > OnKeyPress="__doPostBack(blah...)" - all with the same effect.
    >
    > The form submits itself, as you;d expect, but then when it returns,
    > everything is reset to when the page was first loaded (eg. txtbox is set
    > to
    > "Type here" etc). It's like it's reloading the page from scratch, and
    > ignoring ViewState. ViewState is switched on thouh.
    >
    > I don't know whats wrong - any suggestions on how to do this!?
    >
    > I should point out that the textbox and hidden imagebutton are in a user
    > control - dunno if that makes any diff?
    >
    > Cheers
    >
    >
    >
    > Dan
     
    Ferret Face, Aug 25, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    846
    Purvi T
    Oct 19, 2004
  2. Xavier Osa
    Replies:
    0
    Views:
    634
    Xavier Osa
    Jan 9, 2004
  3. Amy
    Replies:
    0
    Views:
    990
  4. Image Button onkeypress

    , Jul 20, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    570
    Stump
    Aug 12, 2010
  5. Image Button onkeypress

    , Jul 25, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    210
Loading...

Share This Page