我试图制作一系列的检查箱,以更新跟踪检查箱数量(如12个检查箱中的4个)。 I ve创设了“ Java”字典功能updateS selected
,该功能处理的是,它要求识别检查箱的长短和类别,以便计算,因此,我尝试用这一代码生成每个检查箱:
@Html.CheckBox(string.Format("contentprofilestate[{0}].selected", i),
new { onclick = "updateSelected( " + selectedSpanId + " , " + checkboxClass + " )" })
产生以下超文本:
<input id="contentprofilestate_6__selected" name="contentprofilestate[6].selected"
onclick="updateSelected('StMarySpan', 'StMaryCheck')"
type="checkbox" value="true" />
How can I get the onclick
event handler to render without escaping the apostrophes? Alternatively, is there a better way to accomplish this task (if so, feel free to use jQuery in your suggestion)?
www.un.org/Depts/DGACM/index_spanish.htm 注:
I created a new project and created this view and it still escaped the apostrophes:
@{
ViewBag.Title = "index";
}
<h2>index</h2>
@Html.CheckBox(string.Format("contentprofilestate[{0}].selected", 0), new { onclick = "updateSelected( " + "test" + " , " + "test2" + " )" })
<> 替代解决方案>
I was not able to figure out how to keep the apostrophes from being escaped, so I wrote some jQuery logic to do what I need without any inline JavaScript:
jQuery(document).ready(function () {
jQuery( :checkbox ).click(function () {
var clientHeader = jQuery(this).closest( .client-header );
var clientCheckedSpan = clientHeader.find( .client-checked );
var inputChecked = clientHeader.find( input:checked );
clientCheckedSpan.text(inputChecked.length);
});
});