enter button

1jaws
1jaws used Ask the Experts™
on
I have master page has logintextbox and password textbox and Login button. And on default page I have form with several textboxes and button.

I want my to login "when I click enter button " what I need to do?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I have my login button working if I physically click it, and does all those login in stuff ok.. what I need, instead of clicking Login button, if I use my keyboard Enter button to login automatically...
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Author

Commented:
if I have something like, still not working for some reason, what is wrong don't know

<script type="text/javascript">
       
        function pageLoad() {
            var email = $find('<%= txtLoginEmail.ClientID %>');            
            if ($('#<%= txtLoginEmail.ClientID %>').val()) {
                $('#' + '<%= txtLoginPassword.ClientID %>').focus();
                $('#<%= chkRememberMe.ClientID %>').attr('checked', true);
            }
            else
                setTimeout(" email.focus();", 200);
        }      
                         
    </script>
Top Expert 2010

Commented:
try to just wrap everything in a asp panel and set the default button

<asp:Panel ID="LoginPanel" runat="server" DefaultButton="[b]btnLogin[/b]"> 

//other control like text box and button here
//replace btnlogin with you buttoncontrolname
</asp:Panel>

Open in new window


hope this helps!

Author

Commented:
what you mean by that?
//replace btnlogin with you buttoncontrolname
Top Expert 2010

Commented:
what is the name of your login button ? can you post the html ?

Author

Commented:
<td style="font-size: 10px; text-align: left;">
                            <telerik:RadTextBox ID="txtLoginEmail" runat="server" EmptyMessage="Email" />
                        </td>
                        <td style="font-size: 10px; text-align: left;">
                            <telerik:RadTextBox ID="txtLoginPassword" runat="server"  TextMode="Password" EmptyMessage="Password" />
                        </td>
                        <td>
                            <telerik:RadButton ID="btnLogin" runat="server"  Text="Login" OnClick="btnLogin_Click" />
                        </td>
Top Expert 2010
Commented:
yup so .. the name ius btnLogin

cover this table in an asp panel

<asp:Panel ID="LoginPanel" runat="server" DefaultButton="btnLogin">

//table containing the HTML for the login
</asp:Panel>

let me know if this works!

Author

Commented:
nope, it doesnt work
it is not login in when I hit enter
Top Expert 2010

Commented:
well since it is inside the masterpage make sure that you have typed something in the txtLoginEmail before you hit enter.

or do you want to imitate btnLogin click if you just press enter key anywhere in the form ?

Author

Commented:
because i have remember me, it remembers email and I enter password but still enter key not working
Top Expert 2010

Commented:
can you please post the html with the panel that you used now ?  and also make sure that you have not set default button in the code behind.

But I still need the html to take a look at it!
Top Expert 2010
Commented:
Also, Can try to change the radbutton to normal asp:button and see if it does any change ?
Kusala WijayasenaSoftware Engineer
Commented:
Put this into you page load and check

protected void Page_Load(object sender, EventArgs e)
{
	Page.Form.DefaultButton = btnLogin.UniqueID; 
}

Open in new window


-Kusala

Author

Commented:
Ok, I have changed from radbutton to regular asp button and Kusala I put that code too, still not working.

? I both tried to put this code in master page code behind page load didnt work, and tried both on default page which using master page where my btnLogin is there too, still no luck
Kusala WijayasenaSoftware Engineer

Commented:
Could you please attached the full HTML of page referring here

-Kusala

Author

Commented:
would I put this code in master page or default page using master page?
Page.Form.DefaultButton = btnLogin.UniqueID;
Kusala WijayasenaSoftware Engineer

Commented:
Put to the default page where "btnLogin" is located. And also don't change Teleric controls to normal ASP.NET controlls here

-Kusala

Author

Commented:
btnLogin is located  in master page though. default page is using master page also.

Author

Commented:
here my master page
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
         <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <div class="page">
        <div class="header">
            <div class="title">
               
                
            </div>
            <div class="loginDisplay" style="float: right;">
                <table cellpadding="0" cellspacing="5">
                    <tr>
                        <td>
                            <asp:Label ID="lblLoginError" runat="server" Text="No matching records" Visible="false" />
                        </td>
                        <td>
                           
                        </td>
                        <td style="font-size: 10px; text-align: left;">
                            <telerik:RadTextBox ID="txtLoginEmail" runat="server" EmptyMessage="Email" />
                        </td>
                        <td style="font-size: 10px; text-align: left;">
                            <telerik:RadTextBox ID="txtLoginPassword" runat="server"  TextMode="Password" EmptyMessage="Password" />
                        </td>
                        <td>
                           <%-- <telerik:RadButton ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />--%>
                           <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td style="font-size: 10px; text-align: left;">
                            <asp:CheckBox ID="chkRememberMe" runat="server" Checked="false" /><span style="position: relative;
                                top: -3px;">Remember Me</span>
                        </td>
                        <td style="font-size: 10px; text-align: left;">
                            <asp:HyperLink ID="hrefForgotPassword" runat="server" Text="Forgot Password?" NavigateUrl="forgotPassword.aspx" />
                        </td>
                        <td style="vertical-align: top;">
                        </td>
                    </tr>
                </table>
               
            </div>
            <div class="clear">
            </div>
          
        </div>
        <div class="main">
            <asp:ContentPlaceHolder ID="MainContent" runat="server" />
        </div>
        <div class="clear">
        </div>
    </div>
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Open in new window

Author

Commented:
protected void Page_Load(object sender, EventArgs e)
        {
            Page.Form.DefaultButton = btnLogin.UniqueID;
        }

Open in new window


code behind of master page.. and for some reason  now , it throws error says Object reference not set to an instance of an object.  for btnLogin .. it is so weird
Top Expert 2010
Commented:
here is the modified html . can you try this ?

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            <telerik:radscriptmanager id="RadScriptManager1" runat="server" />
            <div class="page">
                <div class="header">
                    <div class="title">
                    </div>
                    <asp:Panel ID="LoginPanel" runat="server" DefaultButton="btnLogin">
                        <div class="loginDisplay" style="float: right;">
                            <table cellpadding="0" cellspacing="5">
                                <tr>
                                    <td>
                                        <asp:Label ID="lblLoginError" runat="server" Text="No matching records" Visible="false" />
                                    </td>
                                    <td>
                                    </td>
                                    <td style="font-size: 10px; text-align: left;">
                                        <telerik:radtextbox id="txtLoginEmail" runat="server" emptymessage="Email" />
                                    </td>
                                    <td style="font-size: 10px; text-align: left;">
                                        <telerik:radtextbox id="txtLoginPassword" runat="server" textmode="Password" emptymessage="Password" />
                                    </td>
                                    <td>
                                        <%-- <telerik:RadButton ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />--%>
                                        <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td style="font-size: 10px; text-align: left;">
                                        <asp:CheckBox ID="chkRememberMe" runat="server" Checked="false" /><span style="position: relative;
                                            top: -3px;">Remember Me</span>
                                    </td>
                                    <td style="font-size: 10px; text-align: left;">
                                        <asp:HyperLink ID="hrefForgotPassword" runat="server" Text="Forgot Password?" NavigateUrl="forgotPassword.aspx" />
                                    </td>
                                    <td style="vertical-align: top;">
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </asp:Panel>
                    <div class="clear">
                    </div>
                </div>
                <div class="main">
                    <asp:ContentPlaceHolder ID="MainContent" runat="server" />
                </div>
                <div class="clear">
                </div>
            </div>
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Open in new window



Also please take out the Page.Form.DefaultButton = btnLogin.UniqueID; from the code behind!

hope this helps.

Author

Commented:
put that on and took out page load and here my default page (test) aspx and this code is not working still

<%@ Page Title="" Language="C#" MasterPageFile="~/Test.Master" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Testing.Test1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
   
    
</asp:Content>

Open in new window

Author

Commented:
Thanks guys! I figured it out .. It was telerik controls was preventing this to happen. Changed to all asp controls and works great now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial