title: Issue trying to find a control inside a MasterPage
body: <p>I am trying to change the DATA attribute in an html <code>&lt;div&gt;</code> tag using C# in the code-behind file for an asp.page.</p>
  
  <p>This is my HTML Code  </p>
  
  <pre><code>&lt;div class="tile page-content" id="fullTextArticle"
                      data-ID=""
                      data-permission="" runat="server"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is my c# in the code-behind file  </p>
  
  <pre><code>private void DisplayFullTextArticle()
          {
  
  
              string contentID = "";
  
              if (Context.Request.QueryString["contentID"] != null)//check for a value in the query string
              {
                  contentID = Context.Request.QueryString["contentID"];
  
                  try 
                  {
  
                      //define connection string                
                      string connString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
  
                      using (SqlConnection conn = new SqlConnection(connString))//create connection object
                      {
  
                          SqlCommand cmd = new SqlCommand("spDisplayFullTextArticle", conn);
  
                          cmd.CommandType = CommandType.StoredProcedure;
  
                          conn.Open();
  
                          cmd.Parameters.Add("@ID", SqlDbType.Int).Value = Convert.ToInt32(contentID);
  
                          SqlDataReader myReader = cmd.ExecuteReader();
  
                          HtmlControl divDataID = FindControl(id: "fullTextArticle") as HtmlControl;
  
  
                          while (myReader.Read())
                          {
                              divDataID.Attributes["class"]= myReader["ID"].ToString();
  
                          }
  
                          myReader.Close();                      
  
                          //}//end using statement for SqlCommmand Object
  
                      }//end using statement for SQLConnection
  
                  }//end try block
  
                  catch (Exception ex)
                  {
  
                  } //end catch block
  
              }//end if statement
  
  }
  </code></pre>
  
  <p>Some context: My method gets a value from the query string and passes the value to a stored procedure which runs a SELECT query to pull full text content from a SQL database. I used break points to do some debugging and I can see the query string does pass the value to the procedure and it runs the query successfully. The trouble is that my HtmlControl variable, divDataID, ends up being null. So the ID value is not being set, so the <code>&lt;div data-ID&gt;</code> attribute is not being set in the browser.</p>
  
  <p>Does anyone know what I'm doing wrong? How do I set the data-ID attribute from the code-behind file?</p>