gpt4 book ai didi

asp.net-mvc - 设置 Html.TextBox 的值 Html 属性 (MVC 1.0)

转载 作者:行者123 更新时间:2023-12-02 00:48:03 30 4
gpt4 key购买 nike

我正在通过 HtmlHelper 创建 Html 文本框,但无法获取值属性集。我已经尝试了下面的两行,我也用谷歌搜索但找不到解决方案:

<%= Html.TextBox("name", null, new { @class = "textbox", value = "hi" }) %>
<%= Html.TextBox("name", null, new { @class = "textbox", @value = "hi" }) %>

这两行都返回一个带有 value=""的输入元素

我错过了什么?

最佳答案

该值是 Html.TextBox 方法的第二个参数:

<%= Html.TextBox("name", "hi", new { @class = "textbox" }) %>

应该可以

关于asp.net-mvc - 设置 Html.TextBox 的值 Html 属性 (MVC 1.0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1874831/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com