这是我在页面中使用的 ListBox 的 Razor 语法。如何设置它的高度和宽度?这里 noCategories 是来自 Controller 的视图数据。
$ @Html.ListBox("noCategories");
控制器:
public ActionResult Configure(int? nopCategoryid)
{
model = new DataImporttModel();
DisplaynopCommerceCategories(model, nopCategoryid);
return View("Nop.Plugin.Data.Import.Views.DataImport.Configure", model);
}
private void DisplaynopCommerceCategories(DataImporttModel model, int? nopCategoryid)
{
var _categoryservice = new NopEngine().Resolve<ICategoryService>();
MultiSelectList sl;
model.nopCommerceCategories = new List<CS_ListItems>();
foreach (var item in _categoryservice.GetAllCategories().ToList())
{
model.nopCommerceCategories.Add(new CS_ListItems() { Name = item.Name, ID = item.Id });
}
if (nopCategoryid != null)
{
sl = new MultiSelectList(model.nopCommerceCategories, "ID", "Name", new[] { nopCategoryid });
}
else
{
sl = new MultiSelectList(model.nopCommerceCategories, "ID", "Name");
}
ViewData["nopCommerceCategories"] = sl;
}
public class DataImporttModel
{
public List<C_Category> Mappings { get; set; }
public List<CS_ListItems> ClockCategories { get; set; }
public List<CS_ListItems> nopCommerceCategories { get; set; }
}