views:

337

answers:

2

Hi all, 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?

Thanks, kapil

+1  A: 

You should use jQuery and attach a handler for the change event in your document.ready

$('#mySelect').change(function(e) {
var val = $(this).val();
});
Keith Rousseau
A: 

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.

Mattias Jakobsson