472,988 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 software developers and data experts.

keypress event of TextBox - WebForm

What code (javascript) will cause a WebForm to be submited (runatserver) whenever a new character is typed into a TextBox from the keyboard?
Nov 18 '05 #1
2 17954
I'd imagine something to do with the onKeypress event, but can you elaborate
on this requirement? This will be ~extremely~ slow.


Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"mg" <mg@theworld.com> wrote in message
news:0B**********************************@microsof t.com...
What code (javascript) will cause a WebForm to be submited (runatserver)

whenever a new character is typed into a TextBox from the keyboard?
Nov 18 '05 #2
I think it is important for you to understand how a webform can be
submitted in ASP.NET.
The form is submitted with no _EVENTTARGET which will
result in no event being fired.Eventhough the page events will fire.
The clent side _doPostBack event is fired before the form is submitted.This
will set an _EVENTTARGET, and fire an event server
side.After the form is submitted the submitting button contrbutes a
name/value pair which will override any value you pre-set in the
_EVENTTARGET hidden field.

Let me come back to your specific case :
You can post back the form using javascript using the
keyup or keydown events and an <input type=submit>(no need it to be
runat="server") button.
For eg:
If you have a TextBox server control with ID TextBox1 and input submit
button with id,Button1 and the id of the webform is Form1,
You can add a client side keyup event on Page_Load by
putting the below code :

TextBox1.Attributes.Add("onkeyup","document.Form1. Button1.click();return
If you want it for a specific key or keys you need
to modify the javascript with checking event.keyCode.
This will add the client side event to the TextBox1 which
will call the click event of the submit button when the onkeyup event
happens for TextBox1.
This will cause your webform to be submitted !!!!
And now some additional TIP:
If you want to Pre-Set the
_EVENTTARGET you can do it by
If you have a server control with ID Button2,

Page.RegisterHiddenField( "__EVENTTARGET", "Button2" );
This will
cause the event in Button2 to be fired when the Web Form is submitted!!
I am not very clear about your
requirement.Anyway hope this helps.
Marshal Antony
..NET Developer

"mg" <mg@theworld.com> wrote in message
news:0B**********************************@microsof t.com...
What code (javascript) will cause a WebForm to be submited (runatserver)

whenever a new character is typed into a TextBox from the keyboard?
Nov 18 '05 #3

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

Similar topics

by: Wiktor Zychla | last post by:
in my application I sometimes use KeyPress event. in the event handler I have to check the char the user is trying to type. in NTs everything is correct. however on W98 I've noticed that the...
by: Top Gun | last post by:
I am trying to trap on a keypress "+" event and convert it to a tab for a high-speed dataentry form that is done entirely from a 10-key. However, I do NOT want the "+" character to be passed on to...
by: Darryn Ross | last post by:
Hi, I am trying to catch the KeyPress event on my datagrid but it isn't working... i have also tried registering the handler with the event like this... dgGLBatch.KeyPress += new...
by: Hal Gibson | last post by:
Because of a legacy (originally DOS) Sub Procedure "AlphaInput" that is called in thousands of places in our code, I need to be able to set a variable, "KeyedString",to the value of TextBox.Text...
by: KC | last post by:
I'm trying to build a simple text editor in part of my app. Right now I'm just testing the basics of the KeyPress event handler. The code is basic...real simple. I'm just testing stuff - Private...
by: Tom | last post by:
I have a VB.NET user control that I wrote - this control has three or four other controls on it (textbox, combobox, datetime picker, etc). Now, whenever the control is on a form and the user enters...
by: Kay | last post by:
Hi all, I want to create a small function to monitor the keystroke. For example, if user key in a comma, I want to replace it with a single quote(etc)... In vb6 I an simply check the KeyAscii...
by: Dusty Hackney | last post by:
Hello, I am programming aspx pages in VB ASP.NET. When using Windows forms, I am able to use an event called KeyPress. However, I haven't been able to get this to work in a Web Form. What do...
by: windy | last post by:
I got a question about keypress event on textbox: I found that the keypress event doesn't invoked when i press the "." button on alphabetic keyboard, however if i use numberpad's "." button...
by: Jason Huang | last post by:
Hi, How do I override a TextBox's KeyPress evnt? And how do we use it? Thanks for help. Jason
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.