473,800 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JS OnKeyPress causes button click

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="Tex tChange" - where TextChange is a public C#
method in Codebehind, I've tried
OnKeyPress="jav ascript:documen t.form1.submit( )" and ive just tried
OnKeyPress="__d oPostBack(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
Nov 19 '05 #1
1 2025
You might have to start messing with the PostBack method(s).

What to the group gurus think?

"dhnriversi de" <da*@musoswire. com> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
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="Tex tChange" - where TextChange is a public
C#
method in Codebehind, I've tried
OnKeyPress="jav ascript:documen t.form1.submit( )" and ive just tried
OnKeyPress="__d oPostBack(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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4199
by: Albert Wagner | last post by:
I have included a file below that tests onKeyPress in Opera 7.11. I am getting peculiar behavior. When the file is first loaded, pressing the keypad + causes the textarea to get physically larger on the screen, and pressing the keypad - causes the textarea to get physically smaller. I click on the scrollbar then this behaviour stops and subsequent keystrokes are displayed appropriately. Is this some kind of bug in Opera 7.11? ...
2
1580
by: JohnR | last post by:
Wow, this is unbelieveable. I've narrowed it down to a few lines of code. Create a new project in VB.NET and put 2 buttons on it (a FBD button and an EXIT button) and enter these lines for the click events: Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click End End Sub Private Sub btnDoFBD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDoFBD.Click
7
4104
by: Kev | last post by:
I need to make some specific alterations to some JavaScript in webpages in order to comply with government guidelines on accessibility. Apparently, whenever the OnClick event is used, it must be accompanied by an alternative OnKeyPress event. The guidelines are very vague and I am not sure what this means. I have used the following piece of JavaScript inside the cell of a table: onclick="window.open('http://www.etc') Do I need to...
6
4946
by: juglesh | last post by:
hello, I just want to be able to use a keypress to do the same as clicking a link. such as will 'click' a certain link, while will 'click' a different link. thanks for your time, juglesh B>{)}
3
2171
by: dhnriverside | last post by:
Hi I've got the following in my aspx <asp:textbox id="findwhat" OnKeyPress="javascript:suggest()"></asp:textbox> and the suggest function function suggest() {
0
1830
by: Tom Edelbrok | last post by:
I'm using VS 2005 to develop an intranet asp.net web application and I get a weird situation. If I start out with any ASPX page that contains an ImageButton control followed by a TextBox control, everything works okay. I can press <ENTER> when the cursor is inside the text box and the page is running, and no events fire (this is what I expect). But as soon as I drop a second text box on the page (ie: after th first one) then pressing...
3
5178
by: Robert Inder | last post by:
I am struggling to catch kestrokes within an Internet Explorer 6 window. My window happens to be displaying three frames, though I suspect a similar problem would arise with a single document. The "<body.." tag in each frame includes an "onKeyPress" handler to catch and act on key presses. And if I focus the window by clicking on the content of one of the documents, keystrokes are sent to the handler on its "<body..." tag.
3
5988
by: Nitinkcv | last post by:
Hi, I have a textbox which takes in values and besides it there is a submit button. Currently on click of the submit button calls a java script function and redirects to a page. So currently after entering the values on hitting the enter on the keyboard does not call the JS Function. So how can i went on to implement this where on hitting enter it calls my JS function: JavaScript Function: function txtKeywordKeyPress() {
5
22027
by: hannie | last post by:
onKeyPress does not work in Firefox. If use tab to navigate each field and press "Enter" on "Next" button to submit form and process to the next form / page, IE works well even if without onKeyPress code. However, Firefox supresses onKeyPress on submit when "Enter" key is pressed. e.which and code="13" does not work for submit button at all in Firefox nor by changing code to focus(). e.g. use tab to navigate each field, when tab goes...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.