Professional Documents
Culture Documents
Key Pressing Events in VBNet
Key Pressing Events in VBNet
Net
Employee ID(Textbox) is there, I have to press F1 key in that textbox, after pressing F1 key a GridView should be displayed ( POP UP ) . How to write code for key pressing
events. Anyone help me plzzz. It is very urgent, for my project.
Thanks in Advance
.NET 2.0 VISUAL STUDIO 2005 ASP.NET 2.0 GRIDVIEW TEMPLATE VISUAL BASIC.NET VISUAL STUDIO WEB FORMS "ASP.NET 2.0" VISUAL STUDIO 2005 2008 ASP .NET 2.0 VB.NET EMAIL FORMS
function allowalpha(objevent)
{
var keypressed=objevent.keyCode;if (keypressed==37) 'you need to search on internet for key code of F1 and replace that with 37
{
return false;
}
else
return true;
}
Hi,
Attach onkeypress event to the textbox control and specify the javascript function to check the event keycode. If the keycode is of F1, write the code to display the popup
page.
See the sample below and let me know if you could achieve the solution.
<html>
<body>
<script type="text/javascript">
function ShowHelp(e)
{
var keynum;
var keychar;
var numcheck;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
keychar = String.fromCharCode(keynum);
CHECK HERE if it is the keychar you want and then display the popup. But I think you have to use non-function keys as function keys will
not be trigerring the keypress events
}
</script>
<form>
<input type="text" onkeypress="return ShowHelp(event)" />
</form>
</html>
on HTML
This site is managed for Microsoft by Neudesic, LLC. | © 2021 Microsoft. All rights reserved.