asp.net mvc 3 - Add custom click event in each option of mvc3 dropdown in c# -


I want to create a custom dropdown in mvc3 c #, so each option in the dropdown can be provisioned to add click events. I do not want to like any option jquery or manually create a loop to add attributes. There is no way to create a custom dropdown using HTML9 or base class. Please help me in this regard.

Suppose it is your dropdown, then you use the following methods to define events You can. Selection list, as new {onchange = "this.form.submit ()"})

  & lt;% = Html.DropDownList ("DDL", viewdata ["Maileist"]) )   

and in your jquery code:

  $ (document) .ready (function () {$ ("# ddl").) {Var StrSelected = ""; $ ("# Ddl Options: Selected"). Each (function () {strSelected + = $ (this) [0] .value;}) var url = "/ Home / MyAction /" + Struggle selected; $ Post (url, function (data) {// when necessary)}}}};});    

Comments