473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

keypress event of TextBox - WebForm

mg
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 17981
I'd imagine something to do with the onKeypress event, but can you elaborate
on this requirement? This will be ~extremely~ slow.

--
Thanks,

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
Hi,
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
false;");
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.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com





"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

0
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...
1
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...
3
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...
0
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...
2
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...
4
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...
7
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...
1
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...
3
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...
2
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
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.