Saturday 19 January 2013

JQuery Keydown Event in ASP.NET

JQuery Keydown Event in ASP.NET
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>JQuery Keydown Event in ASP.NET</title>
    <script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script language="javascript" type="text/javascript">

        $(document).ready(function () {
            $("#txtbox").keydown(
            function (e) {

                if (event.keyCode == 13) {
                    $("#lblShow").text("You have pressed Enter Key");
                }
                else if (event.keyCode == 32) {
                    $("#lblShow").text("You have  Pressed Spacebar Key");
                }
                else if (event.keyCode == 18) {
                    $("#lblShow").text("You have  Pressed Alt Key");
                }
                else if (event.keyCode >= 48 && event.keyCode <= 57) {
                    $("#lblShow").text("You have  Entered Numeric values");
                }
                else if (event.keyCode == 27) {
                    $("#lblShow").text("You have Pressed Escape Key");
                }
                else if ((event.keyCode >= 65 && event.keyCode <= 90) || (event.keyCode >= 97 && event.keyCode <= 122)) {
                    $("#lblShow").text("You have  Entered Alphabet Key");
                }
                else {
                    $("#lblShow").text("You have  Presses Alphabet Key" + e.keyCode);
                }
            }
        );

        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <h4>JQuery Keydown Event in ASP.NET</h4>
    <hr />
    <b>Enter in Textbox</b><br />
    <asp:TextBox ID="txtbox" runat="server" />
    <asp:Label ID="lblShow" runat="server" ForeColor="Red"></asp:Label>
    <br />
    <br />
    </form>
</body>
</html>



output

No comments:

Post a Comment

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.