title: Reflection to add css class to body tag c#
body: <p>I have masterpage which has runat="server" &amp; Id set on body tag. see below</p>
  
  <pre><code>&lt;body id="MasterPageBodyTag" runat="server"&gt;  
  </code></pre>
  
  <p>code behind on masterpage  I've added the following code:</p>
  
  <pre><code>    public HtmlGenericControl BodyTag
  {
      get { return MasterPageBodyTag; }
      set { MasterPageBodyTag = value; }
  }
  </code></pre>
  
  <p>now I want to add css class to body tag from Class1.cs file in App_code folder.</p>
  
  <p>On the .aspx am passing the master page control using the following code:</p>
  
  <pre><code>  protected void Page_Load(object sender, EventArgs e)
  {
      backend.FindPage((PageTemp)this.Master);
  
  }
  </code></pre>
  
  <p>Now on Class1.cs I have the following</p>
  
  <pre><code>  public static void FindPage(Control mp)
  {
  
      Page pg = (Page)HttpContext.Current.Handler;
  
  
      PropertyInfo inf = mp.GetType().GetProperty("BodyTag");    
  </code></pre>
  
  <p>}</p>
  
  <p>I want to  add the following to found BodyTag</p>
  
  <pre><code> //      BodyTag.Attributes.Add("class", "NewStyle");
  </code></pre>
  
  <p>But can't seem to find a way to add atrribute or cast the inf to HtmlGenericControl.</p>
  
  <p>Any help would be great.</p>