Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7891135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:32:26+00:00 2026-06-03T06:32:26+00:00

Possible Duplicate: Submit Login control button when I hit Enter I have a Login.aspx

  • 0

Possible Duplicate:
Submit Login control button when I hit Enter

I have a Login.aspx page with:

<asp:Login ID="MainLogin" runat="server" onloggingin="MainLogin_LoggingIn"></asp:Login>

Code-behind:

protected void MainLogin_LoggingIn(object sender, LoginCancelEventArgs e)
{                    
   SqlConnection myConnection = new SqlConnection(DBConnection.GetConnectionString());
   SqlCommand myCommand = new SqlCommand("SELECT * FROM Users WHERE login=@login and pass=@pass", myConnection);
   myCommand.Parameters.AddWithValue("login", MainLogin.UserName);
   myCommand.Parameters.AddWithValue("pass", MainLogin.Password);
   myCommand.Connection.Open();
   SqlDataReader Reader = myCommand.ExecuteReader();
   while (Reader.Read())
   {
      Session["curUserRole"] = Reader["role"].ToString();
      Session["curUserLogin"] = MainLogin.UserName;                    
      FormsAuthentication.RedirectFromLoginPage(MainLogin.UserName, MainLogin.RememberMeSet);                
      return;
   }
   //Reader.Close();
   //myCommand.Connection.Close();
   //myConnection.Close();                                              
}

A user types his login and password, and then presses the “login” button of the component to login. When the user types his login and password and then presses ENTER on his keyboard, the page login.aspx reloads.
How to fix that? I need that pressing ENTER on keyboard has the same behavior as pressing the login button on the component.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:32:28+00:00Added an answer on June 3, 2026 at 6:32 am

    I think this can be achieved using a Panel wrapper, in conjunction with the DefaultButton property. You’ll need to set the default button to be <LoginControlId>$LoginButton, like so:

    <asp:Panel runat="server" DefaultButton="MainLogin$LoginButton">
        <asp:Login ID="MainLogin" runat="server" onloggingin="MainLogin_LoggingIn">
        </asp:Login>
    </asp:Panel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: HTML: Submitting a form by pressing enter without a submit button How
Possible Duplicate: JavaScript post request like a form submit I have a value calculated
Possible Duplicate: Symfony2 AJAX Login I have implemented a custom authentication handler service to
Possible Duplicate: CSS sticky footer My page has content where as users submit content,
Possible Duplicate: Bind textbox to 'enter' key I have a search text box. I
Possible Duplicate: Associated model is not saving data when page is refreshed I have
Possible Duplicate: How to submit the app to app store? I have access to
Possible Duplicate: cURL: Just trying to download a page I'm trying to submit this
Possible Duplicate: Submit form without page reloading Hi I need to submit a form
Possible Duplicate: Multiple submit buttons in an HTML form I have web form with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.