title: How to get HtmlGenericControl by string in C#
body: <p>I want to add a css class to a li tag in code behind given the id of the li tag.</p>
  
  <pre><code>&lt;li id="liOne" runat="server" class=""&gt;&lt;/li&gt;
  </code></pre>
  
  <p>Here is my c# code:</p>
  
  <pre><code>System.Web.UI.HtmlControls.HtmlGenericControl ctrl = Page.FindControl("liOne") as System.Web.UI.HtmlControls.HtmlGenericControl;
  if(ctrl!=null)
    ctrl.Attributes["class"] += " active";
  </code></pre>
  
  <p>I have tried the above method but it returns null. Is there any method that does not require iterating over all page controls to get the li tag? Thanks.</p>