title: How can I cast an ASP.NET Label?
body: <p>I have an ASP.NET page. I have labels like:</p>
  
  <pre><code>&lt;label id="CalistigiFirmaUnvanLabel" runat="server" style="width: 100%; float: left; font-size: 10pt; font-weight: bold; font-family: Calibri"&gt;
  Çalıştığı Kurumun Unvanı&lt;/label&gt;
  </code></pre>
  
  <p>There are 10 of them in each 15 pages. In a condition, I want to change the innerTexts of these labels. Therefore in Page Load or Init, I want to write something like this:</p>
  
  <pre><code>foreach (Control ctrl in mainDiv.Controls)
  {
      if (ctrl.GetType().BaseType.Equals(CalistigiFirmaUnvanLabel.GetType())
      {
          //if this labels innerText is in my Dictionary, then change it like (Label).InnerText = sth;
      }
  }
  </code></pre>
  
  <p>However, the "Label" cast doesn't work. When I look at the type of <code>calistigifirmaVergiNoLabel</code>, it says it is <code>System.Web.UI.HtmlControls.HtmlGenericControl</code>. When I cast Label for the ctrl inside the inner if, it doesn't have a property "InnerText". How can I cast it? Also, this code takes the div's too. I only want the labels. I deleted the BaseType but then it didn't enter the if statement.</p>