HTML辅助说明 [英] Html Helpers Help

查看:156
本文介绍了HTML辅助说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能推荐一本好书或教程学习有关HtmlHelper类,具体方法 Html.CheckBox() Html.Radio()

Can anyone recommend a good book or tutorial for learning about the HtmlHelper class, specifically methods Html.CheckBox() and Html.Radio()?

推荐答案

希望这些信息将帮助你....我做了足够的R&安培; D于创造更多的HTML控件中的复选框

Hope this information will help you....I did enough R&D on the checkbox which creates additional html control.

始终使用Html.CheckBox()重载方法来创建CheckBox控件。

Always use Html.CheckBox() overload methods for creating checkbox controls.

请注意,复选框帮手(Html.CheckBox())呈现两个输入控件。首先,它使你会期望一个复选框控件,然后它呈现同一个名字的一个隐藏的输入控制。这是要解决的事实,当复选框选中,浏览器不为他们提出任何价值。其隐藏的输入控制设备的MVC框架将收到的隐藏字段的值(即假)时,未选中此复选框。

Notice that the check box helper (Html.CheckBox()) renders two input controls. First, it renders a check box control as you’d expect, and then it renders a hidden input control of the same name. This is to work around the fact that when check boxes are deselected, browsers don’t submit any value for them. Having the hidden input control means the MVC Framework will receive the hidden field’s value (i.e., false) when the check box is unchecked.

从:A press.Pro.ASP.NET.MVC.Framework

From : Apress.Pro.ASP.NET.MVC.Framework.

复选框没有标签。所以与价值添加HTML标签标记的属性为复选框名

Checkbox doesn't have a label. So add the html label tag with for attribute with value as "name of checkbox"

<%= Html.CheckBox("chkAccept1")%><label for="chkAccept1">Accept Terms & Conditions</label>
<input id="chkAccept1" name="chkAccept1" type="checkbox" value="true" /><input name="chkAccept1" type="hidden" value="false" /><label for="chkAccept1">Accept Terms & Conditions</label> 

        <%= Html.CheckBox("chkAccept2", true )%><label for="chkAccept2">Accept Terms & Conditions</label>
 <input checked="checked" id="chkAccept2" name="chkAccept2" type="checkbox" value="true" /><input name="chkAccept2" type="hidden" value="false" /><label for="chkAccept2">Accept Terms & Conditions</label> 

        <%= Html.CheckBox("chkAccept3", false, new { @class="error", @client_selector="alphanumeric" }) %><label
            for="chkAccept3">Accept Terms & Conditions</label>
<input class="error" client_selector="alphanumeric" id="chkAccept3" name="chkAccept3" type="checkbox" value="true" /><input name="chkAccept3" type="hidden" value="false" /><label for="chkAccept3">Accept Terms & Conditions</label>

这篇关于HTML辅助说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆