通过更改MVC4中的另一个下拉列表来绑定下拉列表 [英] Binding dropdownlist by changing another dropdownlist in MVC4

查看:70
本文介绍了通过更改MVC4中的另一个下拉列表来绑定下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的控制器操作方法中,我添加以下代码,我在绑定后传递列表数据

public JsonResult GetMonthByYear(int Year)

{

返回Json(新{ListMonths = Months});



}

视图当我想要检索列表的长度时我收到错误因为Jquery未定义

for(int ind = 0; ind< result.length; ind ++)function =yearchange()={=var =stryear =document.getElementById(Year_ID)。value; if =((stryear)=!=)alert(stryear); =options ={}; options.url = / PO / GetMonthByYear ; options.type = POST ; options.datatype = JSON ; options.data ={year:=$(& quot;#year_id& quot;)。val()=}; =options.success =function(result)=团队=eval('('+ =result.value =&#39;)&#39;); =listitems =; lstmonths = result.ListMonths;长度= result.ListMonths.length; alert(length); =alert(lstmonths.length); =for(int =ind =0; ind< result.length; ind ++)alert(& quot; hello& quot;); =} =$ .ajax(options); =i =added =the =below =references =< script =src =〜/ Scripts /jquery-1.8.3.jstype =text / javascript>< / script> & lt; script =>



请告诉我该怎么办才能解决这个问题?



我尝试过:



Javascript方法显示错误

Hi,
In my controller action method I am adding the below code I am passing list data after binding it
public JsonResult GetMonthByYear(int Year)
{
return Json(new { ListMonths = Months});

}
in view when I want retrieve the length of the list I am getting the error as Jquery is undefined
for(int ind=0;ind<result.length;ind++) function="" yearchange()="" {="" var="" stryear="document.getElementById("Year_ID").value;" if="" ((stryear)="" !=""")" alert(stryear);="" options="{};" options.url=""/PO/GetMonthByYear";" options.type=""POST";" options.datatype=""json";" options.data="{" year:="" $(&quot;#year_id&quot;).val()="" };="" options.success="function" (result)="" teams="eval('('" +="" result.value="" &#39;)&#39;);="" listitems=""";" lstmonths="result.ListMonths;" length="result.ListMonths.length;" alert(length);="" alert(lstmonths.length);="" for(int="" ind="0;ind<result.length;ind++)" alert(&quot;hello&quot;);="" }="" $.ajax(options);="" i="" added="" the="" below="" references="" <script="" src=""~/Scripts/jquery-1.8.3.js"" type=""text/javascript"></script>" &lt;script="">

Please let me know what should I do to resolve thi?

What I have tried:

Javascript method showing error

推荐答案

(& quot;#year_id& quot;)。val()=}; =options.success =function(result)=teams =eval('('+ = result.value =&#39;)&#39;); =listitems =; lstmonths = result.ListMonths;长度= result.ListMonths.length; alert(length); =alert(lstmonths.length); =for(int =ind =0; ind< result.length; ind ++)alert(& quot; hello& quot;); =} =
(&quot;#year_id&quot;).val()="" };="" options.success="function" (result)="" teams="eval('('" +="" result.value="" &#39;)&#39;);="" listitems=""";" lstmonths="result.ListMonths;" length="result.ListMonths.length;" alert(length);="" alert(lstmonths.length);="" for(int="" ind="0;ind<result.length;ind++)" alert(&quot;hello&quot;);="" }=""


.ajax(options); =i =added =the =below =references =< script =src =〜/ Scripts / jquery-1.8.3.jstype =text / javascript>< / script> & lt; script =>



请告诉我该怎么办才能解决这个问题?



我尝试过:



Javascript方法显示错误
.ajax(options);="" i="" added="" the="" below="" references="" <script="" src=""~/Scripts/jquery-1.8.3.js"" type=""text/javascript"></script>" &lt;script="">

Please let me know what should I do to resolve thi?

What I have tried:

Javascript method showing error


这篇关于通过更改MVC4中的另一个下拉列表来绑定下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆