我在我的项目中使用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相关问答推荐

在Docker Windows中,ASP.NET核心容器在自定义端口8080上运行,但ASP.NET容器在固定端口80上运行

ASP.NET @Register 与 @Reference

无法读取配置部分system.servicemodel,因为它缺少部分声明

使用 Lucene.NET 索引 .PDF、.XLS、.DOC、.PPT

GridView 与嵌套类的属性绑定

在 asp.net 中调整图像大小而不会丢失图像质量

HttpModules 的执行顺序是如何确定的?

ASP.NET RadioButton 与名称(组名)混淆

Windows 运行 ASP.NET 的 IIS 替代方案

禁用 web.config 继承?

如何在 ASP.NET 中通过 LAN 访问您的网站

如何在 GridView 中隐藏 TemplateField 列

调查 Web.Config 重复部分原因的步骤

global.asax 中的 Application_Error 未捕获 WebAPI 中的错误

如何进入 IIS 管理器?

ContentResult 与字符串

根据条件更改 GridView 行 colored颜色

使用 FileUpload Control 获取文件的完整路径

Session.Clear() 与 Session.RemoveAll()

Appdomain 回收究竟是什么