JS OnKeyPress causes button click

Discussion in 'ASP .Net' started by Guest, Aug 24, 2005.

  1. Guest

    Guest Guest


    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?


    Guest, Aug 24, 2005
    1. Advertisements

  2. Guest

    Ferret Face Guest

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

    What to the group gurus think?
    Ferret Face, Aug 25, 2005
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.