加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 输入无效的MVC5占位符

发布时间:2020-12-15 23:45:16 所属栏目:百科 来源:网络整理
导读:我的代码是这样的 @Html.EditorFor(model = model.CreatedUser,new { htmlAttributes = new { @class = "form-control",@placeholder = "Your Placeholder Text" }}) 我希望占位符能够在代码中添加,但它没有显示.谁能指出我做错了什么? 输出HTML input clas
我的代码是这样的

@Html.EditorFor(model => model.CreatedUser,new { htmlAttributes = new { @class = "form-control",@placeholder = "Your Placeholder Text"  }})

我希望占位符能够在代码中添加,但它没有显示.谁能指出我做错了什么?
输出HTML

<input class="text-box single-line" id="CreatedUser" name="CreatedUser" type="text" value="" autocomplete="off" style="cursor: auto;  background-attachment: scroll; background-position: 100% 50%; background-repeat: no-repeat;">

解决方法

接受htmlAttributes的EditorFor重载只是MVC 5.1.

见HERE

如果不能选择升级,请使用TextBoxFor:

@Html.TextBoxFor(model => model.CreatedUser,new { @class = "form-control",@placeholder = "Your Placeholder Text" })

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读