How can I use a:
with an asp.net button?
I have done like this.
Markup:
CodeBehind Page_Load()
FixGlyph(phButtonToLabelsAdminBox, btnSave, "icon-ok")
FixGlyph(phButtonToLabelsAdminBox, btnClear, "icon-refresh")
And the Sub:
Private Sub FixGlyph(ph As PlaceHolder, btn As Button, IconClass As String, Optional CustomLabelStyle As String = "")
If btn.Visible = False Then Exit Sub
Dim g As New HtmlGenericControl
g.ID = "labelFor_" + btn.ID
g.TagName = "label"
g.Attributes.Add("for", btn.ClientID)
g.Attributes.Add("class", "" + btn.CssClass + "")
If Not CustomLabelStyle = "" Then g.Attributes.Add("style", CustomLabelStyle)
g.InnerHtml = " " + btn.Text
ph.Controls.Add(g)
btn.Attributes.Add("style", "display:none;")
End Sub
I use ordinary asp:Button in my Markup and the only things are that to run the FixGlyph after other code that might set visible true/false for the buttons and to add the FixGlyph in the order you want the buttons to appear. Other than that, it works for me.