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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:15:36+00:00 2026-06-04T06:15:36+00:00

I have a page that is rendered via an ActionResult called EntityIndex that takes

  • 0

I have a page that is rendered via an ActionResult called EntityIndex that takes int id as a parameter and loads that entity.

On this view a user can select from a dropdown other related entities and the view should reload by sending the selected ID from the dropdown to the same Action EntityIndex with the new ID.

I’m using a jQuery change event on the dropdown to navigate and reload the page:

$("#RelatedEntity").change(function () {
    window.location = '@Url.Action("EntityIndex", new {id = ""})' + '/' + $(this).val();
});

This is the Action

public ActionResult EntityIndex(int id) {
    ... gets entity by id here ...
    return View(model);
}

The action works fine when hit but the jQuery line above is failing with an error:

http://localhost:1798/Entity/EntityIndex/@Url.Action("EntityIndex", new {id = ""})/539

For some reason the window.location firing the @Url.Action is treating the action as a string and not an action to navigate to… what is wrong with the Url.Action that keeps it from behaving correctly?

  • 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-04T06:15:37+00:00Added an answer on June 4, 2026 at 6:15 am

    Your JQuery is ever-so-slightly off. Using the default route and specifying no ID will generate:

    /controller/action/

    So all you need to do is put your value on the end. Try this:

    $("#RelatedEntity").change(function () {
        window.location = '@Url.Action("EntityIndex")' + $(this).val();
    });
    

    Should give you (assuming value is 23):

    /controller/action/23

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

Sidebar

Related Questions

I have a page that uses another page via the include() function. The page
I have a page that looks like this: Head and body tags... <form runat=server>
I have some AJAX calls that render PartialViewResults via the jQuery.AJAX method. This works
I have a table of data from mysql rendered on page via PHP into
I have a page that works perfectly when it's rendered upon page load. (My
I have an HTML page that is converted to PDF via wkhtmltopdf. Everything works
So I have this website that will be accessed via an SSL connection (
I have to display sélection? in one of page that is viewed via iframe.
I have a layout Jade view that has a menu via unordered list, and
I have a page that builds out a table. Nothing else on that page

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.