Dropdown selected changed event in mvc4 using Database First
How to implement Dropdown selected changed event in mvc4 using database first approach.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 5, 2013, 9:02 PM EDT
You have to use handle the change event using jQuery as like this,
in cshtml,
@Html.DropDownListFor(m => m.Id, ListToBeBound as IEnumerable
$(function() {
$('select#someDD').change(function() {
var selectedId = $(this).val();
$.ajax({
url: 'Home/LoadSomething',
type: 'POST',
data: JSON.stringify({ selectedId : selectedId }),
dataType: 'json',
contentType: 'application/json',
success: function (data) {
// Do stuff here
});
error: function (data) {
// Do stuff here
});
});
[HttpPost]
public ActionResult LoadSomething(int selectedId)
{
//Do stuff & return value.
return Json(managers);
}
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 7, 2013, 4:38 AM EDT
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 7, 2013, 4:39 AM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 7, 2013, 6:18 AM EDT
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 7, 2013, 9:22 PM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 8, 2013, 9:46 PM EDT
Here is an good example for DB first & here is a solution for Dropdownlist
Sasi ReddyRank #4,458 · 342 reputationPosted Oct 9, 2013, 11:34 PM EDT