asp.net-mvc-3 – 如何在剃须刀视图中设置复选框?

我需要认选中一个复选框:

我试过所有这些,没有什么是检查我的复选框 –

@Html.CheckBoxFor(m => m.Allowrating,new { @value = "true" })

@Html.CheckBoxFor(m => m.Allowrating,new { @checked = "true" })

@Html.CheckBoxFor(m => m.Allowrating,new { @checked = true })

@Html.CheckBoxFor(m => m.Allowrating,new { @checked = "checked"})

解决方法

您应该将Allowrating属性设置为true,最好在控制器或模型中。 像其他输入一样,复选框的状态反映了该属性的值。

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....