title: assigning css class to a masterpage control from contentpage in asp.net
body: <p>I have a unordered list in my master page....</p>
  
  <pre><code>&lt;ul id="mainMenu" runat="server"&gt;
  &lt;li id="mainHome" runat="server"&gt;&lt;a href="#" title="Home" class="home"&gt;
          &lt;span&gt;&lt;/span&gt;Home&lt;/a&gt;&lt;/li&gt;
  &lt;li id="mainManage" runat="server"&gt;&lt;a href="Users.aspx" title="Manage" 
      class="manage"&gt;&lt;span&gt;&lt;/span&gt;Manage&lt;/a&gt;&lt;/li&gt;
   &lt;li id="mainEnquiry" runat="server"&gt;&lt;a href="account.aspx" title="Enquiry" 
       class="enquiry"&gt;&lt;span&gt;&lt;/span&gt;Enquiry&lt;/a&gt;&lt;/li&gt;
   &lt;li id="mainReport" runat="server"&gt;&lt;a href="EnquiryReport.aspx" title="Report" 
        class="report"&gt;&lt;span&gt;&lt;/span&gt;Report&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  </code></pre>
  
  <p>From a content page i am assigning a css class to one of the list item...</p>
  
  <pre><code>HtmlGenericControl home = (HtmlGenericControl)this.Page.Master.FindControl("mainMenu").FindControl("mainManage") as HtmlGenericControl;
                  string cssToApply = "current";
  
                  if (null != home)
                  {
                      if (home.Attributes.ContainsKey("class"))
                      {
                          if (!home.Attributes["class"].Contains(cssToApply))
                          {
                               home.Attributes["class"] += " " + cssToApply;
                          }
                      }
                      else
                      {
                           home.Attributes.Add("class", cssToApply);
                      }
                  }
  </code></pre>
  
  <p>and my css,</p>
  
  <pre><code>#header ul li {
  display:inline;
  float:left;
  }
  #header ul a {
  -x-system-font:none;
  color:#FFFFFF;
  display:block;
  font-family:Trebuchet MS,Arial,sans-serif;
  font-size:1.1em;
  font-style:normal;
  font-variant:normal;
  font-weight:bold;
  text-transform:uppercase;
  text-decoration:none;
  }
  #header ul a {
  -moz-border-radius:3px;
  -webkit-border-radius:0.2em;
  padding:3px 7px;
  text-decoration:none;
  }
  #header ul a:focus, #header ul a:active, #header ul a:hover {
  background-color:#829E7E;
  outline-color:-moz-use-text-color;
  outline-style:none;
  outline-width:medium;
  }
  #header ul a.home {
  margin:0 16px 0 17px;
  }
  #header ul #current a, #headermenu #current span{ /*currently selected tab*/
  background-color: #BCE27F;
  color:#666666;
  white-space:nowrap;
  }
  #header ul a.manage,#header ul a.enquiry,#header ul a.report {
  margin:0 14px 0 0;
  }
  #home #header ul a.home, #enquiry #header ul a.enquiry, #report #header ul a.report, #manage #header ul a.manage{
  -moz-border-radius:3px;
  -webkit-border-radius:0.2em;
  background-color:#B9E27F;
  color:#FFFFFF;
  }
  </code></pre>
  
  <p>But i get the error,</p>
  
  <p><code>System.Web.UI.AttributeCollection' does not contain a definition for 'ContainsKey' and no extension method 'ContainsKey' accepting a first argument of type 'System.Web.UI.AttributeCollection' could be found (are you missing a using directive or an assembly reference?</code></p>
  
  <p>I am trying to assign <code>current</code> to <code>Manage</code> li from my content page to my master page... Any suggestion...</p>