views:

174

answers:

1

Ok, I thought I knew how to do this.... even though it has been one year since I last programmet .Net.

Update: I've moved my code from the MasterPage to an aspx Template. And still nothing is displayed.

In my aspx templatefile I have the following code:

<asp:Content ContentPlaceHolderID="mainAndRightRegion" runat="server">
       My label: <asp:Label ID="txtString" CssClass="myTestLabel" runat="server" />
</asp:Content>

In my code behind, I have the following code:

private void Page_Load(object sender, System.EventArgs e)
{
  this.txtString.Text = "TEST";
}

What am I mssing here?

A: 

Its possible that postback / viewstate handling in the child-page is blowing out the values you have set in the master page.

Try moving the second block of code, where you are setting testLabel.Text = "Test" to the prerender event handler.

Jeff Fritz
Load event should be safe for this, unless something else is over-writing it later.
Joel Coehoorn
Should be safe... but this is in the MASTER page, which triggers the Load event before the Page's Load event.
Jeff Fritz
yeah, that's what I though.I will try this and see what happends.
Steven
Ok, now I've moved it into an aspx template file, but it still doesn't work. Weird. Any suggestions?
Steven