MVC在VIEW中动态控制htmlAttributes的方法

@{
IDictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("class", "selectpicker");
dic.Add("data-style", "btn-co2;");
}
@Html.DropDownList("drpdept", (SelectList)ViewData["deptList"], "--Select One--", dic)

 

 

这个是直接在页面当中编写,@{} 代表中的代码相当于在后台代码写法

posted @ 2017-02-09 12:22  —阿峰—  阅读(263)  评论(0编辑  收藏  举报