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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sasi ReddyPosted Oct 10, 2013, 3:34 AM
Jaganathan BantheswaranPosted Oct 9, 2013, 1:46 AM
Here is an good example for DB first & here is a solution for Dropdownlist
Sasi ReddyPosted Oct 8, 2013, 1:22 AM
Jaganathan BantheswaranPosted Oct 7, 2013, 10:18 AM
Sasi ReddyPosted Oct 7, 2013, 8:39 AM
Sasi ReddyPosted Oct 7, 2013, 8:38 AM
Jaganathan BantheswaranPosted Oct 6, 2013, 1:02 AM
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);
}