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 8121995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:41:27+00:00 2026-06-06T05:41:27+00:00

Hoping someone can help. I am working on an aspx site, using the c#

  • 0

Hoping someone can help. I am working on an aspx site, using the c# as the code behind. I have 3 input boxes, however when my cursor is in one of the input boxes, it seems to fire off the search_Click code which is fine if the cursor was in in the searchBox, but it seems to do it when the cursor is in the Username and Password Textbox. I dont have any javascript firing off this event, and what wanted to do was if user is in searchBox and hits enter, they fire the Search_Click otherwise if they are in either the username or password textbox and hit enter they fire off te code associated to login_Click. Hope that makes sense, anyone know why its firing the Response.Redirect even though I have no javascript/jquery teling it to.

//Front end aspx page
<input type="text" class="searchBox" autocomplete="off" id="searchBox" name="searchBox" runat="server" />
<asp:Button ID="searchBtn" class="searchBtn" runat="server" onclick="search_Click" />

<li>
  <asp:Label ID="UserNameLabel"  AssociatedControlID="UserName" runat="server" Text="Username :" CssClass="usernamelabel" />
  <asp:TextBox ID="UserName" runat="server" ValidationGroup="RegisterValidationGroup" CssClass="Username-Password" />                     
</li>
<li>
  <asp:Label ID="PasswordLabel"  AssociatedControlID="Password" runat="server" Text="Password :" CssClass="usernamelabel" />
  <asp:TextBox ID="Password" runat="server" ValidationGroup="RegisterValidationGroup" TextMode="Password" CssClass="Username-Password" />
</li>
<li>
  <asp:Button ID="loginBtn" class="loginBtn" Text="Login" runat="server" onclick="Login_Click" />
</li>



//C# Code behind
protected void search_Click(object sender, EventArgs e)
{
    Response.Redirect("/SearchResults.aspx?q=" + Server.UrlPathEncode(searchBox.Value));
}
  • 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-06T05:41:29+00:00Added an answer on June 6, 2026 at 5:41 am

    Unless I’ve misunderstood your question, you can use the DefaultButton property of an asp:Panel object

    For your login use something like… (untested)

    <asp:Panel runat="server" DefaultButton="btnLogin">
      <asp:TextBox runat="server" id="txtUsername" />
      <asp:TextBox runat="server" id="txtPassword" TextMode="Password"/>
      <asp:Button runat="server" id="btnLogin" Text="Login" />
    </asp:Panel>
    

    And then for your search have… (untested)

    <asp:Panel runat="server" DefaultButton="btnSearch">
      <asp:TextBox runat="server" id="txtSearch" />
      <asp:Button runat="server" id="btnSearch" />
    </asp:Panel>
    

    The idea behind this is that if the focus is on a asp:TextBox within the asp:Panel, pressing enter will initiate the DefaultButton. If you don’t want a particular one to cause a post-back to the server, then update the DefaultButton so that it automatically cancels, such as…

    <asp:Button runat="server" id="btnSearch" OnClientClick="return false;" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im hoping someone can help me quickly with a question i have. As site
Im hoping someone can help me with a small problem! I have a php
I'm hoping someone can help. I have a banner rotator which works fine on
I am hoping someone can help me with a question i have relating to
I'm really hoping that someone can help. I have tomorrow to get this right
Hoping someone can help with this. I have other VM's that dont have problems,
So I've already got this working but I'm hoping someone can help me optimize
I am hoping someone can help me. I have a very simple question, but
I am working with javascript and classic asp, I am hoping someone can help
I have an issue I'm hoping someone can help with. I have an application

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.