多选下拉列表在mvc5中不起作用 [英] multiselect dropdown is not working in mvc5

查看:99
本文介绍了多选下拉列表在mvc5中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我使用的是mvc5。我为多选下拉列表构建了一个应用程序。我下载并添加js&css文件for multiselect但它不工作







应用程序正在运行好..但多选下拉不来......请帮助我解决这个问题:





控制器:

< pre lang =" cs"> public ActionResult Index()

{



var emp = new Class1( );

emp.emlist.Add(new SelectListItem(){Text =& quot; Select Employee& quot;,Value =& quot; 0& quot;});

var employeelist = t.customers.ToList();

foreach(var v in employeelist)

{

emp.emlist .Add(new SelectListItem(){Text = v.name,Value = v.ID.ToString()});

}



返回查看(emp);

}< / pre>





查看:



@model multiselect.Models.Class1



@ {

ViewBag.Title =" Index";

}



< h2>索引< / h2>

& lt; script src ="〜/ Content / jquery-multiselect.js">& lt; / script> ;

< link href ="〜/ Content / jquery-multiselect.css"的rel ="样式表" />

@ Html.ListBoxFor(model => model.eid,new System.Web.Mvc.MultiSelectList(Model.emlist," Value"," Text",Model.emlist) ),new {@class =" emplist"})

< pre lang =" xml">& lt; script type =& quot; text / javascript& quot;& ; gt;

$(function(){

$(& quot; .emplist& quot;)。multiselect({multiple:true,header:& quot ;选择状态& quot;});

});

& lt; / script& gt;< / pre>

Hi friends,
I am using mvc5. I built one application for multiselect dropdownlist. I download and add js & css file for multiselect but it is not working



Application is running good.. but multiselect dropdown is not come..pls help me to solve this issue:


Controller:
<pre lang="cs">public ActionResult Index()
{

var emp = new Class1();
emp.emlist.Add(new SelectListItem() { Text = &quot;Select Employee&quot;, Value = &quot;0&quot; });
var employeelist = t.customers.ToList();
foreach(var v in employeelist)
{
emp.emlist.Add(new SelectListItem() { Text = v.name, Value = v.ID.ToString() });
}

return View(emp);
}</pre>


View:

@model multiselect.Models.Class1

@{
ViewBag.Title = "Index";
}

<h2>Index</h2>
&lt;script src="~/Content/jquery-multiselect.js">&lt;/script>
<link href="~/Content/jquery-multiselect.css" rel="stylesheet" />
@Html.ListBoxFor(model => model.eid, new System.Web.Mvc.MultiSelectList(Model.emlist, "Value", "Text", Model.emlist), new { @class = "emplist" })
<pre lang="xml">&lt;script type=&quot;text/javascript&quot;&gt;
$(function () {
$(&quot;.emplist&quot;).multiselect({ multiple: true, header: &quot;Select status&quot; });
});
&lt;/script&gt;</pre>

推荐答案

(function(){
(function () {


(& quot; .emplist& quot;)。multiselect({multiple:true,header: & quot;选择状态& quot;});

});

& lt; / script& gt;< / pre>
(&quot;.emplist&quot;).multiselect({ multiple: true, header: &quot;Select status&quot; });
});
&lt;/script&gt;</pre>


请参考以下文章:



使用DropD MVC 5中的ownList使用jQuery


这篇关于多选下拉列表在mvc5中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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