asp.net mvc ajax -


I am using the dropdownlist html assistant and when the value changes, I would like to call an AJAX call on the server. I've seen jquery code dropdownlist.change ...

The problem I have is that I have a series of dropdownlist_1 dropdownlist_1, dropdownlist_2, ... ...

I would like to be able to specify the same jquery function for each of these dropdown lists. I can not find a way to specify the function name in the dropdownlist html helper.

Thanks, Henry

Instead of specifying it in HtmlHelper, click on each of your dropdowns Add a class name for the lists:

  <%> Html.DropDownList ("ddlName", new {@ class = "ajaxDropDown"})%>  

or

  & lt; Select class = "ajaxDropDown" id = "ddlOne" & gt; & Lt; Options & gt; 1 & lt; / Options & gt; & Lt; Options & gt; 2 & lt; / Options & gt; & Lt; Options & gt; 3 & lt; / Options & gt; & Lt; / Select & gt; & Lt; Select class = "ajaxDropDown" id = "ddl two" & gt; & Lt; Options & gt; Red & lt; / Options & gt; & Lt; Options & gt; Orange & lt; / Options & gt; & Lt; Options & gt; Blue & lt; / Options & gt; & Lt; / Select & gt;  

Then use the classname to hook the event through jQuery:

  $ ('. AjaxDropDown'). Change (function () {$ .get ('/ test', function (data) {...});});  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -