Click here to Skip to main content
14,608,246 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hai
How to use enter key from keyboard to login in web application not use focus().pls reply asap


Regards
Aravind
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 2

Below is the sample code for you. Hope it will help

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"  runat="server">
    <title>Untitled Page</title>
 
    <script language="Javascript">
 
function CheckKey() {
    switch (event.keyCode) {
    case 13:
    Login();
    break;
    default:
    //nothing
    }
}
 
function Login(){
document.getElementById("btnLogin").click();
}


   </script>

</head>
<body >
    <form id="form1"  runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        
    </div>
    <asp:Button ID="btnLogin" runat="server" Text="Login" />
    </form>
    <script>
document.body.onkeydown=CheckKey();

</script>
</body>
</html>
   
v2
Comments
Aravindba 31-May-13 1:31am
   
Thanx for ur reply,in web site we have master page,so other than login page all are not having head,body section, so i need above code if i use master page
Mahesh Bailwal 31-May-13 2:01am
   
I updated my solution.
You can use below javascript code inside your web form to attach keydown event handler. Make sure to add this script tag at end of your .aspx page.

<script>
document.body.onkeydown=CheckKey();

</script>
Rate this:
Please Sign up or sign in to vote.

Solution 3

Put your login controls inside a Panel and set the DefaultButton property of the panel as your Login Button.
<asp:Panel runat="server" ID="pnlLogin" DefaultButton="btnLogin">
     Put your login textboxes and buttons here.
</asp:Panel>



--Amit
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 4

<asp:panel id="p" runat="server" defaultbutton="myButton" xmlns:asp="#unknown">
  <%-- Text boxes here --%>
  <asp:button id="myButton" runat="server" />
</asp:panel>


May this Help You
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100