Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > JS OnKeyPress causes button click

Reply
Thread Tools

JS OnKeyPress causes button click

 
 
=?Utf-8?B?ZGhucml2ZXJzaWRl?=
Guest
Posts: n/a
 
      08-24-2005
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
 
Reply With Quote
 
 
 
 
Ferret Face
Guest
Posts: n/a
 
      08-25-2005
You might have to start messing with the PostBack method(s).

What to the group gurus think?

"dhnriverside" <> wrote in message
news:CE5E10B2-576A-4857-8C8D-...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Datagrid Control 0 05-25-2004 01:45 AM



Advertisments
 



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