我在我的项目中使用Bootstrap 3,我想在ASP中使用Bootstrap图标.网络按钮.

下面是我使用的代码,尽管没有成功(我得到了一个使用Twitter bootstrap <span>个标签而不是<i>个标签的示例):

<asp:Button ID="btnRandom"
    runat="server"
    Text="<span aria-hidden='true'
        class='glyphicon glyphicon-refresh'>
        </span>"
    onclick="btnRandom_Click" />

也许应该做些额外的事情.

我怎么才能让它工作呢?提前感谢您的回复.

推荐答案

你必须使用asp:LinkButton instead of a asp:Button,以下是我在ASP中使用Bootstrap 3时的工作原理.NET web应用程序:

通过代码,您可以完成以下工作:

<asp:LinkButton ID="btnRandom" 
            runat="server" 
            CssClass="btn btn-primary"    
            OnClick="btnRandom_Click">
    <span aria-hidden="true" class="glyphicon glyphicon-refresh"></span>
</asp:LinkButton>

下面是一个例子,我用Submit Button加上"提交"的文字:

<asp:LinkButton ID="SubmitBtn" 
                runat="server" 
                CssClass="btn btn-primary"    
                OnClick="SubmitBtn_Click">
    <span aria-hidden="true" class="glyphicon glyphicon-ok"></span>Submit
</asp:LinkButton>

Asp.net相关问答推荐

如何在 asp.net 服务器中使用字体

如何根据另一个下拉列表中的 Select 从下拉列表中删除一个值?

Asp.Net Core 创建一个控制器来使用 SendGrid 发送邮箱

什么是 SNIReadSyncOverAsync,为什么需要很长时间才能完成?

从 asp.net 中的 Web.config 获取连接字符串

如何注册路由区域

当前http上下文的http动词

iframe.readyState 在 chrome 中不起作用

用于链接字符串中的 url 的 C# 代码

从 GUID 中删除破折号是个好主意吗?

Request.Params 和 Request.Form 什么时候不同?

如何使用 ASP.Net MVC 路由来路由图像?

ASP.NET MVC4 异步控制器 - 为什么要使用?

如何以编程方式将标签的前景色设置为其默认值?

为 ASP.NET Core MVC 显示 404 Not Found 页面

用于呈现

.NET AJAX 调用 ASMX 或 ASPX 或 ASHX?

ASP.NET:在 Response.Redirect(...) 之后代码会发生什么?

哪个事件先调用?母版页 Page_Load 或内容页 Page_Load

Application_End global.asax