asp.net-mvc - How Can I add a dollar symbol in ASP.NET MVC5?
问题描述
How do I add a dollar symbol in front of a TextBox, which cannot be edited? I want to have the dollar symbol so people don't need to type '$' by themselves. Here is my code:
@Html.Label("lblP1", "Rate 1", htmlAttributes: new { @class = "control-label", @style = "margin-right: 30px" })
<br />
@Html.EditorFor(m => m.Pricing.Price1, null, new { htmlAttributes = new { @type = "string", @class = "form-control" } })
解决方案
这是使用引导程序的示例:
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">$</span>
</div>
@Html.EditorFor(m => m.Pricing.Price1, null, new { htmlAttributes = new { @type = "string", @class = "form-control" } })
</div>
来源:https ://getbootstrap.com/docs/4.0/components/input-group/
推荐阅读
- typescript - 将类注入自定义存储库
- bert-language-model - “您必须指定 input_ids 或 inputs_embeds”,但我确实指定了 input_ids
- python - PySide6.1 与 matplotlib 3.4 不兼容
- spring-boot - 带有 keycloak 的 Spring Boot 安全性不适用于 graphql
- javascript - 如何在点击时使图像全屏?
- javascript - 如何检查 Chrome 扩展程序中是否已注入脚本?
- python - 从 OpenModelica 生成的 .mat 文件中导出 .csv 文件
- visual-studio-2019 - 使用 Visual Studio 2019 中的一个登录按钮进行管理员和用户登录
- flutter - 如何设置 Switch 的 onChanged 值
- angular - .Net Core Windows 身份验证,授权访问特定 AD 组