我想在我的编辑视图中输入类型输入复选框,
这适用于我的模特
.pcap
这是我的Razor View
public partial class iseng
{
public int Id { get; set; }
public string hobi1 { get; set; }
public string hobi2 { get; set; }
public string hobi3 { get; set; }
}
如何解决?
答案 0 :(得分:0)
function SendEmailWithCustomTitle(txtEmail, txtContents, l_strTitle) {
event.preventDefault();
$.ajax({
async:false,
type: "POST",
url: "PTServiceRoutines.aspx/AjaxSendEmail",
data: "{'p_strEmail':'" + txtEmail + "','p_strTitle':'" + l_strTitle + "','p_strContents':'" + txtContents + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: successAjaxSendEmailWithCustomTitleHandler,
failure: failureAjaxSendEmailWithCustomTitleHandler,
error: errorAjaxSendEmailWithCustomTitleHandler
});
return false;
}
function successAjaxSendEmailWithCustomTitleHandler(data) {
ShowAlert(data.d);
//ShowAlert is method used to open modal showing data.a
};
function failureAjaxSendEmailWithCustomTitleHandler(data) {
};
function errorAjaxSendEmailWithCustomTitleHandler(data, status) {
};
答案 1 :(得分:0)
@Html.EditorFor(x => x.Remember)
将生成:
<input id="Remember" type="checkbox" value="true" name="Remember" />
<input type="hidden" value="false" name="Remember" />
它是如何运作的:
如果未选中复选框,则表单仅提交隐藏(false) 如果选中,则表单提交两个字段(false和true),MVC设置为bool属性为真
<input id="Remember" name="Remember" type="checkbox
value="@Model.Remember"/>
如果选中
,这将始终发送默认值