从代码后面添加twitter glyphicon

时间:2015-02-27 18:03:02

标签: asp.net twitter-bootstrap

将图标添加到可以进行静态标记的按钮时

<button id="LoginButton" runat="server" class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-lock"></span>  Login</button>

但是在必须从代码隐藏生成的地方我无法找到添加它的方法 - 我认为这样可行,但是没有......

Dim ViewIcon As New HtmlGenericControl("span")
                        With ViewIcon
                            .Attributes.Add("class", "glyphicon glyphicon-new-window")
                        End With

                        Dim ViewButton As New Button
                        With ViewButton
                            .ID = "DocumentViewButton_" & Row("Document_ID")
                            .CssClass = "btn btn-success"
                            .Text = "View"
                            .ToolTip = "View the Document"
                            .Controls.Add(ViewIcon)
                        End With
                        AddHandler ViewButton.Click, AddressOf ViewDocument

但它只是像这样呈现

<input type="submit" name="ctl00$ContentPlaceHolder1$DocumentViewButton_4" value="View" id="ContentPlaceHolder1_DocumentViewButton_4" title="View the Document" class="btn btn-success" />

任何想法如何实现这一目标?

由于

1 个答案:

答案 0 :(得分:0)

似乎将Button更改为LinkBut​​ton

 Dim ViewIcon As New HtmlGenericControl("span")
                        With ViewIcon
                            .Attributes.Add("class", "glyphicon glyphicon-new-window")
                            .InnerHtml = "  View"
                        End With

                        Dim ViewButton As New LinkButton
                        With ViewButton
                            .ID = "DocumentViewButton_" & Row("Document_ID")
                            .CssClass = "btn btn-success"
                            .ToolTip = "View the Document"
                            .Controls.Add(ViewIcon)
                        End With
                        AddHandler ViewButton.Click, AddressOf ViewDocument