Html.Dropdown list events in MVC [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this questionCan anyone please tell me about -
How can I handle Html.DropDown control's events in MVC View?
Can I handle it using scripts? And how to know about the selected item?You should use jQuery and attach a handler for the change event in your document.ready
$('#mySelect').change(function(e) {
var val = $(this).val();
});
If you use jquery you can handle events something like this:
$("#IdOfYourSelectList").change(function() {
var value = $(this).val();
});
This creates a handler for the change event. If you want to bind a handler to some other event you just replace change with whatever event you want to handle.
The same goes for any html element.
精彩评论