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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:06:26+00:00 2026-06-04T07:06:26+00:00

In my MVC application, I have a html.dropdownlist in my view. On selection changed

  • 0

In my MVC application, I have a html.dropdownlist in my view. On selection changed – I want the value to be passed on to a method (that returns something like a list or a JsonResult) in the controller.

Q1: How do I do this?

 <%=Html.DropDownList("title", Model.Titleitems, "" )%>

Q2: Is this a good practice (having controller/method name in the view directly) or should I write a JavaScript function and call the appropriate controller/method from inside that JavaScript function? In that case, how can I write a Onchange or OnSelectionChanged event for the above html.dropdownlist control?

EDIT:

par1 is the dropdownlist selected value I want to pass to this controller/method..

       public ActionResult GetMethod(string Par1)
        {
            //My code here 

            return Json(varValue, JsonRequestBehavior.AllowGet); 
        }

Now I have the dropdownlist on change taking me to a JavaScript function (as per marteljn suggestion) and in the JavaScript function, I have .ajax call specifying URL and type etc. that takes me to the controller/method code; but still not able to figure out how to pass the selected value to the controller?

  • 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-04T07:06:27+00:00Added an answer on June 4, 2026 at 7:06 am

    Q2 is the answer to Q1. There are no events when using MVC like there are in web forms, so you will write some JavaScript to make a request back to the server.
    There are (at least) two ways to go about it:

    1. Inline Event Handler (not recommended)

      <%=Html.DropDownList("title", Model.Titleitems, new{@onchange = "YourJsFuncHere()"} )%>

    2. The JQuery way,

      $("#title").bind("change",function(){
           //Your Code  
           //Use .on instead of bind if you are using JQuery 1.7.x or higher   
           //http://api.jquery.com/on/ 
      });
      

    Edit – The AJAX Code

    $.ajax({
      "url": "/Controller/Action/" + $("#title").val(),
      "type": "get",
      "dataType" : "json",
      "success": function(data){
        //Your code here
        //data should be your json result
      }
    });
    

    Change GetMethod(string Par1) to GetMethod(string id) or change your default route to reflect the Par1 parameter.

    Also, if its not hitting your break point its possible that 1) the AJAX request is not being initied (use firebug to see if it is) 2) Your routes are not configured properly (Look in Global.asax.cs, if you haven’t moved the routing somewhere else.

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

Sidebar

Related Questions

I have an MVC application view that is generating quite a large HTML table
I have asp.net mvc application, that uses razor view engine. I want to send
ASP.NET MVC application. I have a Html.DropDownList. I want to redirect to another controller
I have some static (pure html) pages in my MVC application that I need
I have a MVC application which has a Controller that has a recursive method
In my MVC application I have a View Model that looks similar to this:
I have this ASP.NET MVC application that I now want to separate out the
I have a rich html textbox on my asp.net mvc application. The rich html
In my ASP MVC 3 application, I have this form @using (Html.BeginForm()) { <input
In my ASP .NET MVC application i have a link that refreshes the preview

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.