0

I have the following dropdown. How can I bind the OnChange method to it?.

I am using Code first MVC approach. Also, how can I get the index value when binding on change method to it?

 <div class="editor-label">
     @Html.LabelFor(model => model.Id, "Empl")
 </div>
 <div class="editor-field">
     @Html.DropDownList("Id", String.Empty)
     @Html.ValidationMessageFor(model => model.Id)
 </div>
lante
  • 7,192
  • 4
  • 37
  • 57
Jot Dhaliwal
  • 1,470
  • 4
  • 26
  • 47

2 Answers2

2

You can use JQuery to bind on change and then get the index then .

Something like this should take care of it..

Community
  • 1
  • 1
Burak Karakuş
  • 1,368
  • 5
  • 20
  • 43
0
@Html.DropDownList("Id", Enumerable.Empty<SelectListItem>(), new { onchange = "changeFunction()" })

That's assuming you want a blank list.