【发布时间】:2011-08-09 14:07:41
【问题描述】:
我正在尝试将复选框列表放在 asp.NET MVC 2 中的简单表单上。这是它的代码:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% using (Html.BeginForm("HandSurvey", "Resources", FormMethod.Post, new { runat="server" }))
{ %>
<asp:CheckBoxList id="chkListChemical" runat="server">
<asp:ListItem>Fiberglass & resins</asp:ListItem>
<asp:ListItem>Heavy duty oil paints & stains</asp:ListItem>
<asp:ListItem>Mechanics - tools, grease/oil</asp:ListItem>
<asp:ListItem>Metalworking fluids</asp:ListItem>
<asp:ListItem>Paint & Stains in use</asp:ListItem>
<asp:ListItem>Exposure to solvents</asp:ListItem>
<asp:ListItem>Difficult soils</asp:ListItem>
<asp:ListItem>Hydrocarbons</asp:ListItem>
</asp:CheckBoxList>
<% }
%>
</asp:Content>
当我点击这个页面时,它给出了这个错误:
“CheckBox”类型的控件“ctl00_MainContent_chkListChemical_0”必须放在带有 runat=server 的表单标记内。
我以为我正确指定了 runat 属性。还是我在这里缺少其他东西?如果我不使用辅助类而只使用常规表单标签,它就可以工作。
【问题讨论】: