views:

86

answers:

1

I have a login box that I need to have submitted when enter is pressed. Below you are going to find part of the code. Please any help would be appreciated.

<div class="box-login clearfix">
    <div class="box-login-header">
        <h3>
            Registered Users</h3>
    </div>
    <div>
        <asp:Label ID="LblMessage" runat="server" ForeColor="Red"></asp:Label>
        <asp:RequiredFieldValidator ID="Rfv_LoginId" runat="server" ControlToValidate="TextLogInId"
            ErrorMessage="Login Id is required" ValidationGroup="A" Display="Dynamic"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ID="RevLoginId" runat="server" ControlToValidate="TextLogInId"
            ErrorMessage="Login id does not contain spaces,double quotes or +&gt;&lt;=';:,|/"
            ValidationExpression="[^ &quot;+&gt;&lt;=':,|/]*$" ValidationGroup="A" Display="Dynamic"></asp:RegularExpressionValidator>
        <asp:RequiredFieldValidator ID="Rfv_Password" runat="server" ControlToValidate="TextPassword"
            ErrorMessage="Password is required" ValidationGroup="A" Display="Dynamic"></asp:RequiredFieldValidator>
        <asp:CustomValidator ID="CvPassword" runat="server" ClientValidationFunction="ValidatePassword"
            ControlToValidate="TextPassword" ErrorMessage="" Display="Dynamic"></asp:CustomValidator>
        <asp:RegularExpressionValidator ID="RevPassword" runat="server" ControlToValidate="TextPassword"
            ErrorMessage="Space is not allowed" ValidationExpression="[^ ]*$" ValidationGroup="A"
            Display="Dynamic"></asp:RegularExpressionValidator>
        <asp:Label ID="LblPassword" runat="server" ForeColor="#FF0066"></asp:Label>
    </div>
    <p>
        Please enter your GoCCL.com Login ID & Password below</p>
    <ul>
        <li>
            <label for="cloginid">
                Login ID:</label>
            <asp:TextBox ID="TextLogInId" runat="server" CssClass="text-box" MaxLength="16" onblur="ClearMessage()"></asp:TextBox>
        </li>
        <li>
            <label for="cpassword">
                Password:</label>
            <asp:TextBox ID="TextPassword" runat="server" TextMode="Password" CssClass="text-box"
                MaxLength="16" onblur="ClearMessage()"></asp:TextBox>
        </li>
    </ul>
    <asp:LinkButton ID="btnForgotPassword" CssClass="forgot" runat="server" Text="Forgot your Login ID or Password?"
        OnClick="btnForgotPassword_Click"></asp:LinkButton>
    <asp:ImageButton ID="CmdLogin" CssClass="btn-login" OnClick="CmdLogin_OnClick" OnClientClick="ClearMessage()"
        runat="server" ImageUrl="/stylesheets/bookccl/images/button/btn-login.gif" CausesValidation="true" />
    <div class="box-login-fotter clearfix">
        <p>
            <strong>New to GoCCL? </strong>
            <asp:LinkButton ID="btnRegistration" runat="server" Text="Register Now" CssClass="register-new"
                OnClick="btnRegistration_Click"></asp:LinkButton>
            to join the fun!</p>
    </div>
</div>
+1  A: 

You could wrap it in a Panel control and set the DefaultButton to the button you want invoked when pressing Enter. There are also other options explored here:

http://www.beansoftware.com/asp.net-tutorials/accept-enter-key.aspx

David