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

  • Home
  • SEARCH
  • 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 9200451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:46:17+00:00 2026-06-17T22:46:17+00:00

I am working with mvc4 and have a field where a user can enter

  • 0

I am working with mvc4 and have a field where a user can enter some text in to an input field which gets passed to the url and redirect to another page eg. /search/<>

My form is as follows but redirects as query string.

<form class="search" action="@Url.Action("Index", "Search")">
<div>
    <input name="q" value="" type="search" />
    <input type="image" name="btn" value="search" src="@Url.Content("/image1.jpg")" />
</div>

</form>

Any idea how I could alter my form to pass the inputed value to input “q” to the url.

  • 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-17T22:46:18+00:00Added an answer on June 17, 2026 at 10:46 pm

    You could use a GET method:

    <form class="search" action="@Url.Action("Index", "Search")" method="get">
        <div>
            <input name="q" value="" type="search" />
            <input type="image" name="btn" value="search" src="@Url.Content("~/image1.jpg")" />
        </div>
    </form>
    

    You could also generate this exact same markup using the Html.BeginForm helper which is designed for this purpose:

    @using (Html.BeginForm("Index", "Search", FormMethod.Get, new { @class = "search" }))
    {
        <div>
            <input name="q" value="" type="search" />
            <input type="image" name="btn" value="search" src="@Url.Content("~/image1.jpg")" />
        </div>
    }
    

    When you use the GET method all input element values will be sent in the query string when the form is submitted.

    And if you want to append the search string in the path portion of the url instead of using a query string parameter I invite you to read the following blog post from Scott Hanselman. I will quote only his conclusion:

    After ALL this effort to get crazy stuff in the Request Path, it’s
    worth mentioning that simply keeping the values as a part of the Query
    String (remember WAY back at the beginning of this post?) is easier,
    cleaner, more flexible, and more secure.

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

Sidebar

Related Questions

Actually I'm working on simple project MVC4 + EF in which I have relation
Hi all i am working on mvc4 i have some issue here i am
I am currently working on MVC4 SinglePage Application. I have a Web Api method
I have a MVC 4 project I am currently working on and need some
I am working on a Single Page Application in MVC4. I have a dropdown
I have an MVC4 application that I am working on and I am trying
I have a Kendo Grid in MVC4 that is working fine: Html.Kendo().Grid<SearchUserResultViewModel>() .Name(Grid) .Columns(columns
I have an MVC4 project, and I am trying to get it working on
I have a razor view in an MVC4 project that treats the same input
I am working on mvc4 application using EF code first approach. I have finished

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.