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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:08:30+00:00 2026-05-31T20:08:30+00:00

Hello my question is an exact replica of ASP.NET MVC Routing , Html.BeginForm ,

  • 0

Hello
my question is an exact replica of ASP.NET MVC Routing , Html.BeginForm ,
im posting again because the suggested solution doesnt work..
my View:

@using (@Html.BeginForm("Search", "Home",FormMethod.Get))
{
        input name="q" id="q" type="text" class="ipt" />
        @Html.DropDownList("SearchType", new SelectList(
      new[] { "All Words", "Any Word", "ZipCode" }, ("All Words")))


        input type="image" src="../../Content/images/search.png" />
}

(i’ve removed < character so it shows in the question)
the generated url is this http://localhost:4893/Home/Search?q=Brabant&SearchType=ZipCode&x=51&y=5, i want it to be Home/Search/Brabant/ZipCode


EDIT :

i dont think it has something to do with routes, the javascript doesnt work! my problem is generating the url in first place, not matching it.

$('form').submit(function () {
        var data = $('input[name="q"]', this).val();
        window.location.href = this.action + '/' + encodeURIComponent(data);
        return false;
    });
  • 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-31T20:08:32+00:00Added an answer on May 31, 2026 at 8:08 pm

    The javascript has to be inside the form

    @using (@Html.BeginForm("Search", "Home", FormMethod.Get))
                {
                    <script type="text/javascript">
                        $('form').submit(function () {
                            var q = $('input[name="q"]', this).val();
                            var e = document.getElementById("SearchType");
                            var SearchType = e.options[e.selectedIndex].text;
    
                            var idx = window.location.href.indexOf("/", 7);
                            var siteName = window.location.href.substring(0, idx).replace("http://", "");
                            var newPath = "http://" + siteName + '/' + q + '/' + SearchType;
                            window.location.href = newPath;
                            return false;
                        });
                    </script>
                    <div class="pf sleft">
                        <input name="q" id="q" type="text" class="ipt" />
                        @Html.DropDownList("SearchType", new SelectList(
                  new[] { "All Words", "Any Word", "ZipCode" }, ("All Words")))
                    </div>
                    <div class="pf sright">
                        <input type="image" onclick="return CheckInput();" src="@Url.Content("~/Content/images/search.png")" />
                    </div>
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New question As suggested by Asaph in previous question: Regex to check if exact
Original Question Hello All, I'm a bit confused on how MVC maps HTTP requests
hello everybody i have a question regarding strip_tags function. i have an html document
hello again my question if it is possible to print microsencods using TimesSpan in
hello i have this question i was trying to find a way to call
Hello guys sorry if the question looks stupid to you. i have 3 tables
Hello i have a question on picking random entries from a database. I have
Hello I asked this question to superuser but I did not get a good
First question here so hello everyone. The requirement I'm working on is a small
Hello this is may first question and I have found so far the following

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.