mvc @html.textboxfor 添加正则表示式,如何在C#/ MVC 4中的Html.TextBoxFor中输入占位符文本...
通常在
HTML / CSS中,如果要將占位符文本添加到文本框,則只需執行以下操作:
< input type =“text”class =“input-class”placeholder =“請輸入您的電子郵件”/>
但是因為我正在使用為Visual Studio MVC 4中的登錄面板提供的現有代碼:
/Views/Account/Login.cshtml
這是當前呈現輸入的C#代碼:
@Html.TextBoxFor(m => m.Email, new { @class = "form-input" })
@Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })
@Html.PasswordFor(m => m.Password, new { @class = "form-input" })
@Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
如何在C#中為此代碼添加占位符文本?我試過這個:
@Html.TextBoxFor(m => m.Email, placeholder ="Email" new { @class = "form-input" })
它用紅色標出“占位符”,稱“當前上下文中不存在名稱’占位符’”.
總結
以上是生活随笔為你收集整理的mvc @html.textboxfor 添加正则表示式,如何在C#/ MVC 4中的Html.TextBoxFor中输入占位符文本...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 红米pro android 7,消费降级
- 下一篇: 微型计算机dec al,微机原理复习知识