KeyPress ASP.Net

Hello tyrodeveloper's if you need use KeyPress in ASP.NET, do this:

Step 1. Create a javascript function:
        function txtQTY_KeyPress(e) {
            var key = window.event ? e.keyCode : e.which;
            var btnAdd = document.getElementById("btnAddItem");
            var txt = document.getElementById("txtQTY"); 
            if (key == 13) {

Step 2. Add the keypress attribute to the TextBox Control
txtQTY.Attributes.Add("onkeypress", "txtQTY_KeyPress(event)");

When the user press "Enter" key, shots the Click event of the Button.

Please Click on the +1 button

No hay comentarios:

Publicar un comentario