如何在前端激活按钮类?

发布于 2025-02-14 01:57:44 字数 1990 浏览 0 评论 0原文

您可以在我共享的.cshtml代码中看到的按钮。我想更改这些按钮的类型。但是,无论我做什么,当我在浏览器中运行该应用程序时,按钮会默认。

这就是我所看到的。但是我想这样的一个 - >

<h2>SIMPLE CALCULATOR</h2>
<form asp-action="Calculator" method="post">

    <div class = "border-dark">

               <div class = "form-group">
                 <label for = "FirstNumber">First Number</label>
                 <input type="text" class="form-control" id="FirstNumber" name="FirstNumber" value="@Model.FirstNumber"/>
               </div>

               <div class = "form-group">
                 <label for = "SecondNumber">Second Number</label>
                 <input type="text" class="form-control" id="SecondNumber" name="SecondNumber" value="@Model.SecondNumber"/>
               </div>

               <button type= "submit" class="btn-btn-info" id="addition" value="addition" name="method">+</button>
               <button type= "submit" class="btn-btn-danger" id="substraction" value="substraction" name="method">-</button>
               <button type= "submit" class="btn-btn-warning" id="multiplication" value="multiplication" name="method">*</button>
               <button type= "submit" class="btn-btn-default" id="division" value="division" name="method">/</button>

                <div class = "form-group">
                 <label for = "Result">Result</label>
                 <input type="text" class="form-control" id="ResultNumber" name="ResultNumber" value="@Model.ResultNumber"/>
               </div>
    </div>

</form>

There are buttons as you can see in the .cshtml code I shared. I want to change the type of these buttons. However, no matter what I do, the buttons come as default when I run the application in the browser.

enter image description hereit is what i see. But i want to one of them like that -> enter image description here

<h2>SIMPLE CALCULATOR</h2>
<form asp-action="Calculator" method="post">

    <div class = "border-dark">

               <div class = "form-group">
                 <label for = "FirstNumber">First Number</label>
                 <input type="text" class="form-control" id="FirstNumber" name="FirstNumber" value="@Model.FirstNumber"/>
               </div>

               <div class = "form-group">
                 <label for = "SecondNumber">Second Number</label>
                 <input type="text" class="form-control" id="SecondNumber" name="SecondNumber" value="@Model.SecondNumber"/>
               </div>

               <button type= "submit" class="btn-btn-info" id="addition" value="addition" name="method">+</button>
               <button type= "submit" class="btn-btn-danger" id="substraction" value="substraction" name="method">-</button>
               <button type= "submit" class="btn-btn-warning" id="multiplication" value="multiplication" name="method">*</button>
               <button type= "submit" class="btn-btn-default" id="division" value="division" name="method">/</button>

                <div class = "form-group">
                 <label for = "Result">Result</label>
                 <input type="text" class="form-control" id="ResultNumber" name="ResultNumber" value="@Model.ResultNumber"/>
               </div>
    </div>

</form>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

土豪 2025-02-21 01:57:44

如果您的Web应用程序正在使用Bootstrap(ASP.NET MVC Web应用程序模板中包含Bootstrap)。
Bootstrap 5按钮 -

class=“btn btn-primary”

您正在BTN BTN之间添加额外的破折号“ - ”。尝试删除第一个破折号。

If your web app is using Bootstrap (Bootstrap is included with asp.net mvc web app templates).
Bootstrap 5 buttons -
https://getbootstrap.com/docs/5.0/components/buttons/
The bootstrap documation states:

class=“btn btn-primary”

You’re adding an extra dash “-“ between btn btn. Try removing the first dash.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文