asp.net-mvc – 具有html帮助的布尔隐藏和隐藏

这是怎么回事? viewmodel变量是一个值为true的bool.
<%= Html.HiddenFor(m => m.TheBool) %>
<%= Html.Hidden("IsTimeExpanded",Model.TheBool) %>
<input type="hidden" value="<%=Model.TheBool%>" name="TheBool" id="TheBool">

结果是:

<input id="TheBool" name="TheBool" value="False" type="hidden">
<input id="TheBool" name="TheBool" value="False" type="hidden">
<input value="True" name="TheBool" id="TheBool" type="hidden">

我究竟做错了什么?为什么帮手不按预期工作?

解决方法

1)使用不同的(唯一)ids

2)不要使用这个帮手,使用

<input type="hidden" name="the-name" 
  value="<%= Html.AttributeEncode(Model.TheBool) %>" id="TheBool_1216786" />

相关文章

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