How to use a Twitter Bootstrap icon inside an ASP.NET Button?

后端 未结 5 1744
感动是毒
感动是毒 2021-02-04 09:22

How can I use a:

 

with an asp.net button?

5条回答
  •  囚心锁ツ
    2021-02-04 09:28

    Thanks Anders Smedman, your code sure did the job. here is the C# code if anyone needs it.

     private void FixGlyph(PlaceHolder ph, Button btn, string iconClass, string customLabelStye = "")
        {
            if (btn.Visible)
            {
                var g = new HtmlGenericControl();
                g.ID = "labelFor_" + btn.ID;
                g.TagName = "label";
                g.Attributes.Add("for",btn.ClientID);
                g.Attributes.Add("class","" + btn.CssClass +"");
                if (customLabelStye != "")
                {
                    g.Attributes.Add("style",customLabelStye);
                }
                g.InnerHtml = " " + btn.Text;
                ph.Controls.Add(g);
                btn.Attributes.Add("style","display:none;");
            }
    
        }
    

提交回复
热议问题