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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:59:43+00:00 2026-05-30T16:59:43+00:00

I need to reload my page based on the selection of a value in

  • 0

I need to reload my page based on the selection of a value in a dropdownlist in MVC 3.
My dropdown is defined as such:

@Html.DropDownListFor(model => model.ID, new SelectList(Model.SchoolBranches, "ID", "Name", Model.ID), new { id = "Branches", name = "Branches"})

My script is defined as such so far:

<script type="text/javascript">
    $(function () {
        $("#Branches").change(function () {
            var selected;
            selected = $(this).val();
            alert(selected);
            // make a call to the Index action passing in the 'selected' value to reload the whole page
    });
});
</script>

My selected ID is working fine as the alert show the correct ID on change. Just can’t find any examples that show how to navigate back to the index action and send the new ID. All the samples I have found show partial page or such refresh using ajax. I need the whole page reloaded.

Thanks

UPDATE:

Using @Brandon’s help, I’ve tried these approaches

<script type="text/javascript">
    $(function () {
        $("#Branches").change(function () {
            var selected;
            var url;
            selected = $(this).val();
            url = '@Url.Action("Index", "School")';
            alert(url); //gives /School/Index/55  this is also  my current page in my browser address bar
            url = '@Url.Action("Index", "School", new {id = ""})';
            alert(url); //gives /School
            url = '@Url.Action("Index", "School", new {id = ""})' + '/' + selected;
            alert(url); //gives /School/41 

            // window.location = url;
        });
    });

</script>

This is my route in global.asax just so you can see that I don’t have any crazy routes going on

public static void RegisterRoutes(RouteCollection routes) {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    //routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
    );
}

Update

This works:

url = '@Url.Action("NotIndex", "School", new {id = ""})' + '/' + selected;

I get the correct new Url and the action is hit with the selected ID

  • 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-30T16:59:44+00:00Added an answer on May 30, 2026 at 4:59 pm

    Just set window.location.

    window.location = '@Url.Action("Index", "Controller", new { id = "" })' + '/' + selected;
    

    That should generate the URL to your action (clearing out the current ID) and then append the new route parameter.

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

Sidebar

Related Questions

On my site I need to request a date/time every page reload. The reason
I need to reload the page after I've selected all images. I know that
Purpose : For Google Ads I need to reload a page without loading js
I have a web page where I need periodically update image based on several
I'm trying to get this page reload function to work in the new Opera
There is a javascript-based interface - so I need not to support work without
I have a link in my page that look like this: a href=?command=value but
Possible Duplicate: How to reload a page using Javascript? I have the Facebook login
I have my web applicatoin initialize method run based upon the page that is
I need to reload a block of javascript every amount of time.. say <script

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.