title: how to access master page control from content page
body: <p>I have a master page which contains a label for status messages. I need to set the status text from different .aspx pages.  How can this be done from the content page?</p>
  
  <pre><code>public partial class Site : System.Web.UI.MasterPage
  {
      public string StatusNachricht
      {
          get
          {
              return lblStatus.Text;
          }
          set
          {
              lblStatus.Text = value;
          }
      }
  
      protected void Page_Load(object sender, EventArgs e)
      {            
  
      }
  }
  </code></pre>
  
  <p>I have tried this, but was unsuccessful in making it work:</p>
  
  <pre><code>public partial class DatenAendern : System.Web.UI.Page
  {
      var master = Master as Site;
  
      protected void Page_Load(object sender, EventArgs e)
      {               
          if (master != null)
          {
              master.setStatusLabel("");
          }
      }        
  
      protected void grdBenutzer_RowCommand(object sender, GridViewCommandEventArgs e)
      {           
              try
              {
                  //some code
  
                  if (master != null)
                  {
                      master.setStatusLabel("Passwort erfolgreich geändert.");
                  }
              }
              catch (Exception ex)
              {
                  if (master != null)
                  {
                      master.setStatusLabel("Passwort konnte nicht geändert werden!");
                  }                                       
              }
          }
      }                   
  }
  </code></pre>