Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to access MasterPage label from Child Codebehind
Message
De
11/05/2021 13:57:16
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Titre:
Trying to access MasterPage label from Child Codebehind
Divers
Thread ID:
01680311
Message ID:
01680311
Vues:
36
Hi all

Got a web application that has a Master Page with a label for the Child Page (lblTitle) on it. I'd like to set the lblTitle text from the child pages.

Master ASP
      <asp:ContentPlaceHolder ID="MainContent" runat="server">
        <div>
          <br />
          <asp:Label ID="lblTitle" runat="server" Text="" Font-Bold="true" Font-Size="X-Large" ></asp:Label>
          <br />
        </div>
      </asp:ContentPlaceHolder>
Master code behind
  public string SetMasterTitle
  {
    get { return this.lblTitle.Text; }
    set { this.lblTitle.Text = value; }
  }
Chile Code behind (trying to set lblTitle.text)
      MasterPage master = this.Master;
      if(master != null)
        this.Master.SetMasterTitle = "Transfer - No Offense Report";
I keep getting the error
: 'Object reference not set to an instance of an object.'

lblTitle was null.

So, where am I going wrong?
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform