开发者

Html.Dropdown list events in MVC [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学编程

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 question

Can 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜