473,608 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Webform keydown event and keyup event...help

Ok,
I have tried to do this with the System.Web.UI and can't find anything
for the webform. It seems much easier for a Winform.
Any help in trapping Webform keydown event and keyup event is
appreciated.
Thanks,
Trint

Nov 17 '05 #1
3 3276
What do you mean ?

Whether you are using vanilla HTML or ServerControls, those events are
exposed.

Look in the documentation for the server control you are using.

--
Of all words of tongue and pen, the saddest are: "It might have been"

Bill.Richards @ greyskin .co .uk
http://greyskin.co.uk
"trint" wrote:
Ok,
I have tried to do this with the System.Web.UI and can't find anything
for the webform. It seems much easier for a Winform.
Any help in trapping Webform keydown event and keyup event is
appreciated.
Thanks,
Trint

Nov 17 '05 #2
No,
A webform works totally different. Apparently I need code that looks
something like this under Page_Load (although I need help on this one):

<SCRIPT LANGUAGE="JavaS cript">

<!-- Begin
function currencyFormat( fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true; // Enter
key = String.fromChar Code(whichCode) ; // Get key value from key code
if (strCheck.index Of(key) == -1) return false; // Not a valid key
len = fld.value.lengt h;
for(i = 0; i < len; i++)
if ((fld.value.cha rAt(i) != '0') && (fld.value.char At(i) != decSep))
break;
aux = '';
for(; i < len; i++)
if (strCheck.index Of(fld.value.ch arAt(i))!=-1) aux +=
fld.value.charA t(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}
// End -->
</script>

Any help is appreciated.
Thanks,
Trint
billr wrote:
What do you mean ?

Whether you are using vanilla HTML or ServerControls, those events are
exposed.

Look in the documentation for the server control you are using.

--
Of all words of tongue and pen, the saddest are: "It might have been"

Bill.Richards @ greyskin .co .uk
http://greyskin.co.uk
"trint" wrote:
Ok,
I have tried to do this with the System.Web.UI and can't find anything
for the webform. It seems much easier for a Winform.
Any help in trapping Webform keydown event and keyup event is
appreciated.
Thanks,
Trint


Nov 17 '05 #3
No, Webform does not work totally different:

WebForm ... you either place a ServerControl on it or an HTML control on it.
If you want round trips to your server for processing your data then you use
a ServerControl, if you want to do it all in your client, you use an HTML
control.

What you should notice about the code you have supplied is that it is
JAVASCRIPT, which means you are doing your processing client-side (which is
what you should always do for validation)

All you have to do in the control is add an event handler...

<html>
<script type="text/javascript">
function myKeyPressEvent Handler()
{
alert("you pressed a key");
}
</script>
<body>
<INPUT type="textbox" onkeypress="myK eyPressEventHan dler();" >
</body>
</html>
--
Of all words of tongue and pen, the saddest are: "It might have been"

Bill.Richards @ greyskin .co .uk
http://greyskin.co.uk
"trint" wrote:
No,
A webform works totally different. Apparently I need code that looks
something like this under Page_Load (although I need help on this one):

<SCRIPT LANGUAGE="JavaS cript">

<!-- Begin
function currencyFormat( fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true; // Enter
key = String.fromChar Code(whichCode) ; // Get key value from key code
if (strCheck.index Of(key) == -1) return false; // Not a valid key
len = fld.value.lengt h;
for(i = 0; i < len; i++)
if ((fld.value.cha rAt(i) != '0') && (fld.value.char At(i) != decSep))
break;
aux = '';
for(; i < len; i++)
if (strCheck.index Of(fld.value.ch arAt(i))!=-1) aux +=
fld.value.charA t(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}
// End -->
</script>

Any help is appreciated.
Thanks,
Trint
billr wrote:
What do you mean ?

Whether you are using vanilla HTML or ServerControls, those events are
exposed.

Look in the documentation for the server control you are using.

--
Of all words of tongue and pen, the saddest are: "It might have been"

Bill.Richards @ greyskin .co .uk
http://greyskin.co.uk
"trint" wrote:
Ok,
I have tried to do this with the System.Web.UI and can't find anything
for the webform. It seems much easier for a Winform.
Any help in trapping Webform keydown event and keyup event is
appreciated.
Thanks,
Trint


Nov 17 '05 #4

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

Similar topics

34
4893
by: Andrew DeFaria | last post by:
I thought this would be fairly straight forward but apparently it's not. Given the following html file: <!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <title>Test</title> </head> <body> <form method="post" action="javascript:">
0
1936
by: Ramnadh | last post by:
Hi, I am inherting the Panel call and making another class BasePanel By extending all the properties and including some other members as the base for all the classes. After that i am inheriting that BasePanel Class. How can i register the KeyDown/KeyUp event. As the Protected Access specifier cannot be accessible to multilevel inheritance, how can i made the KeyDown/KeyUp active in the extended Class which inheriting the BasePanel.
2
4092
by: ZS | last post by:
Hi, On a form , I'm trying to trap when a shift key is pressed. Can someone explain how the KeyUp,KeyDown and Key Press event works for Forms. Thanks -ZS
2
18002
by: mg | last post by:
What code (javascript) will cause a WebForm to be submited (runatserver) whenever a new character is typed into a TextBox from the keyboard?
4
7124
by: ShaneO | last post by:
I would like to handle the KeyUp & KeyDown events in the same event handler but can't find how to determine which event was fired - Private Sub ListBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ Handles ListBox1.KeyUp, ListBox1.KeyDown If e.KeyValue = Keys.PageDown Or e.KeyValue = Keys.PageUp Or e.KeyValue = Keys.End Or e.KeyValue = Keys.Home Then
2
1447
by: Gidi | last post by:
Hi, I have a textBox, i want to add after each Keydown Event the char *, i did textbox1=textbox1.Text + "*"; but i can i send the coruser to the end of the line so the next letter will be placed after the * so for example if the user pressed a and then b, i will get a*b*. i need to do it with KeyDown event or KeyPress...
3
5243
by: MLM450 | last post by:
I have a control that handles the KeyDown event but it does not seem to execute when a combination of keys is pressed - like CTRL+Z. If I press CTRL, it executes. If I press Z, it executes. But the handler does not see the combination. Now this control is contained within another control which is contained within another. The top most control does see the CTRL+Z. I can easily pass down the key info, but why does the nested control see...
6
14196
by: mingchin.AT | last post by:
Hi, In Javascript, the simple way to check user input is to get the keycode. But for cross browser, its seems we need to have two different keycodes for the same key. There is a web page for get keycode vs event types. http://www.w3.org/2002/09/tests/keys-cancel2.html
2
19284
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I have created for this purpose is derived from class UserControl.
0
8067
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8010
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8501
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...
1
8157
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
5479
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
3967
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...
1
2477
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1336
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.