0

您好我正在尝试在我的下拉列表中添加复选框。我用谷歌搜索了它,我在 asp.net 中得到了例子,就像我在 MVC3 中尝试做的那样。在我的表单编辑用户必须能够检查下拉列表中的值。例如,在下面的制造商列表表格中,目前它只显示我必须提供的值,并带有与该值关联的复选框。

我的表格:

 <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<EmsAdmin.Models.User>" %>
 <%@ Import Namespace="EmsAdmin.Models" %>

 <script type="text/javascript">
  //<![CDATA[
    // Focus on the first input box for the site
    $(document).ready(function () {
      $('#UserId').focus();
    });
  //]]>
</script>

<%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try again.") %>
<% using (Html.BeginForm()) {%>
  <%= Html.AntiForgeryToken() %>
  <p>
    <%= Html.LabelFor(e=>e.Id,"Id:") %>
    <%: Model.Id %>
  </p>
  <p>
    <%= Html.LabelFor(e=>e.PersonId,"Person:") %>
    <%= Html.DropDownListFor(e => e.PersonId, (SelectList)ViewData["allPersons"], "Select a person", new { @style = "width: 255px;" })%>
    <%= Html.ValidationMessageFor(e=>e.Person,"") %>
  </p>
  <p>
    <%= Html.LabelFor(e=>e.Email,"Email:") %>
    <%= Html.TextBoxFor(e => e.Email, new { @style = "width:250px;" })%>
    <%= Html.ValidationMessageFor(e=>e.Email,"") %>
  </p>
    <%= Html.LabelFor(e=>e.Approve,"Aprrove User:") %>
    <%= Html.CheckBoxFor(e=> e.Approve,Model.Approve) %><span>&nbsp;Switch this on if you want to add regitrar </span>
    <%= Html.ValidationMessageFor(e=>e.Approve,"") %>
  </p>
  <p>
    <%= Html.LabelFor(e=>e.ManufacturerDescription,"Brand:") %>
    <%= Html.DropDownListFor(e => e.ManufacturerDescription, (SelectList)ViewData["allManufacturers"], "Select  Brands", new { @style = "width: 255px;" })%>
    <%= Html.ValidationMessageFor(e=>e.ManufacturerDescription,"") %>
  </p>
  <p>
    <%= Html.LabelFor(e=>e.CountryName,"Country:") %>
    <%= Html.DropDownListFor(e => e.CountryName, (SelectList)ViewData["allCountries"], "Select Countries", new { @style = "width: 255px;" })%>
    <%= Html.ValidationMessageFor(e=>e.CountryName,"") %>
  </p>
  <p>
    <%= Html.LabelFor(e=>e.Role,"Role:") %>
    <%= Html.DropDownListFor(e => e.Role, (SelectList)ViewData["allRoles"], "Select Roles", new { @style = "width: 255px;" })%>
    <%= Html.ValidationMessageFor(e=>e.Role,"") %>
  </p>
  <p>
    <input type="submit" value="Save" />
    <%= Html.ActionLink("Cancel","Details",new {id=Model.Id},new {@title="exit without saving"}) %>
  </p>
<% } %>
4

1 回答 1

2

没有基本的html 输入,例如带有复选框的下拉菜单。您可以使用 DevExpress 等辅助控件库或制作您自己的控件。

在此处查找覆盖基本标记的jquery 插件。

于 2013-07-30T12:51:17.083 回答