title: ASP.Net code behind button with font awesome icon
body: <p>My designer gave me this, which works great:</p>
  
  <pre><code>&lt;button class="btn btn-circle btn-success"&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt;&lt;/button&gt;
  </code></pre>
  
  <p>Standard html button with some bootstrap styling and font awesome icon.</p>
  
  <p>However I dynamically create the buttons at runtime in a table and add them to a placeholder on the page. Now I am battling to get the font awesome icon to display. I use them elsewhere on the site where things are simpler, and the font awesome icons work fine.</p>
  
  <p>Can anyone suggest how I would specify the icons on the buttons at runtime? Real world the icons will be different based on different business logic.</p>
  
  <p>Sample code:</p>
  
  <pre><code>        void Sample()
      {
          phDirectors.Controls.Clear();
          var manager = Context.GetOwinContext().GetUserManager&lt;ApplicationUserManager&gt;();
          var user = manager.FindById(Page.User.Identity.GetUserId());
  
          using (var context = new UserApplicationModelEntities())
          {
              var appId = new Guid(this.hdntbApplicationsId.Value);
              var application = context.tbApplications.FirstOrDefault(app =&gt; app.tbApplicationsId == appId);
  
              Table oTable = new Table();
              oTable.CssClass = "table table-striped";
  
              TableHeaderRow oHead = new TableHeaderRow();
              TableHeaderCell oHCell = new TableHeaderCell();
              TableRow oRow;
              TableCell oCell;
  
              oHCell.Text = "Name";
              oHead.Cells.Add(oHCell);
              oHCell = new TableHeaderCell();
              oHCell.Text = "Verify";
              oHead.Cells.Add(oHCell);
  
              oTable.Rows.Add(oHead);
  
              foreach (tbApplicationsDirectors oDirector in application.tbApplicationsDirectors)
              {
                  oRow = new TableRow();
  
                  oCell = new TableCell();
                  oCell.Text = oDirector.FirstName;
                  oRow.Cells.Add(oCell);
  
                  oCell = new TableCell();
                  Button oButton = new Button();
  
                  oButton.ID = string.Format("{0}", oDirector.tbApplicationsDirectorsId);
                  oButton.CssClass = "btn btn-circle btn-primary";
                  if (oDirector.IDNumber == user.IDNumber)
                  {
                      //oButton.Text = "GO";
                      oButton.Click += OButtonDirectorDetails_Click;
                      oButton.Enabled = true;
                  }
                  else if (oDirector.EmailSent &amp;&amp; !oDirector.EmailVerified)
                  {
                      //oButton.Text = "Resend";
                      oButton.Click += OButtonResend_Click;
                  }
                  else
                  {
                      oButton.Enabled = false;
                  }
  
                  //I tried adding it as a literal, but to no avail.
                  //Literal oIconLit = new Literal();
                  //oIconLit.Text = "&lt;i class=\"fa fa-check\"&gt;&lt;/i&gt;";
                  //oButton.Controls.Add(oIconLit);
  
                  oCell.Controls.Add(oButton);
                  oRow.Cells.Add(oCell);
  
                  oTable.Rows.Add(oRow);
              }
  
              this.phDirectors.Controls.Add(oTable);
  
          }
      }
  </code></pre>
  
  <p>Thanks!</p>