如何将RadioButtonFor()设置为默认选中
<%=Html.RadioButtonFor(m => m.Gender,"Male")%>
Run Code Online (Sandbox Code Playgroud)
(Html.RadioButton)有出路而不是(Html.RadioButtonFor)
有任何想法吗?
我目前在MVC2中开发应用程序我想在我的应用程序中使用多个表单标签在我的视图中我创建了一个具有删除选项的表,我正在通过Post for Individual Delete进行,所以我为每个按钮创建了表单标签.我还希望用户提供删除多个记录的选项,以便我为他们提供复选框.此表单应具有复选框和所有复选框的所有值.所以表格得到渲染像这样
对于每个删除按钮
<form action="/Home/MutipleDelete" method="post">
<input class="button " name="Compare" type="submit" value="Mutipledelete" style="margin-right:132px;" />
<input id="chk1" name="chk1" type="checkbox" value="true" />
<form action="/Home/Delete" method="post">
<input type="submit" class="submitLink" value="member1" />
<input type="hidden" name="hfmem1" id="hfmem1" value="1" />
</form>
<input id="chk2" name="chk2" type="checkbox" value="true" />
<form action="/Home/Delete" method="post">
<input type="submit" class="submitLink" value="member2" />
<input type="hidden" name="hfmem2" id="hfmem2" value="2" />
</form>
</form>
Run Code Online (Sandbox Code Playgroud)
以下不起作用.但如果我以这种方式编写形成渲染的代码
<form action="/Home/MutipleDelete" method="post">
<input class="button " name="Compare" type="submit" value="Mutipledelete" style="margin-right:132px;" />
</form>
<input id="chk1" name="chk1" type="checkbox" value="true" />
<form action="/Home/Delete" …
Run Code Online (Sandbox Code Playgroud) 我正在使用HiddenFor与模型绑定,它绑定值.我想将绑定值重置为零.我该怎么做?
我试过这个,但它不起作用......
<% foreach (var item in Model ) { %>
<%: Html.HiddenFor(model => model.ID,new { @value="0"})%>
<% } %>
Run Code Online (Sandbox Code Playgroud)