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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:09:37+00:00 2026-05-26T12:09:37+00:00

I have an asp.net web form with an html input and button at the

  • 0

I have an asp.net web form with an html input and button at the top that I need to use as a search box. I need to integrate the template for the page with a page written in php so I’m trying to write the search box code as compatible with asp.net and php as I can.

That being said, I don’t want the button to be a submit button since I don’t want it to interfere with any buttons that appear on the page below it that might have to be submit buttons themselves.

When I click the Go button, everything works as expected. A lot of users, myself included, prefer to just hit the enter button and assume it will click the Go button. Since it is not a submit button this will not do, however when I hit return in the textbox, even with code in the onkeydown to run the search/redirect function, all it does is refresh the page.

Search box/button:

<input onkeydown="if (event.keyCode == 13) doSearch() " id="search" type="text" name="search" value="Search" style="width: 116px;" /><input id="btSearch" onclick="doSearch();" style="width: 33px; margin-left: 2px;" type="button" value="Go" />

Search function:

function doSearch() {
    var query = document.getElementById("search").value;
    window.location = "/Search.aspx?" + query;
}

What is intercepting my redirection to the search page when I hit enter?

  • 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-05-26T12:09:37+00:00Added an answer on May 26, 2026 at 12:09 pm

    Can you post the whole form? The default action when you hit enter in a text field in most browsers is to submit the form, so your browser is submitting it after it calls the JS because your handler is not suppressing the default action. Add a return false to do so:

    <input onkeydown="if (event.keyCode == 13) {doSearch(); return false; }" id="search" type="text" name="search" value="Search" style="width: 116px;" /><input id="btSearch" onclick="doSearch();" style="width: 33px; margin-left: 2px;" type="button" value="Go" />
    

    Alternatively, just put the correct ACTION value in the form tag – otherwise the form will not work for users who do not have JavaScript!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp.net(c#) web form with html input text(first name) how i can check
I have an asp.net web form (c#, .NET framework 3.5) that returns to itself
I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a checkbox list control on my asp.net web form that I am
I have a simple form with some plain html input like bellow using ASP.NET
I have an ASP.NET web form which I am adding a variable number User
I have a asp.net web form which will submit information to come as emails.
If I have the following in an ASP.NET Web Form: <asp:TextBox runat=server ID=tbxUser/> and
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For
I have an asp.net url path which is being generated in a web form,

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.