🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

[web] [ASP.NET] MasterPage, Base page class, inherited pages...

Started by
0 comments, last by Krisc 16 years, 3 months ago
I have the following setup... Master.master: - content stuff BasePage : Page - Label, ID=MainLabel - Code that does MainLabel.Text = "..."
<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="ContentPage.aspx.cs" Inherits="FocusedGames.ContentPage" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Label ID="MainLabel" runat="server" Text="Hello" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainColumn" runat="server">
</asp:Content>
ChildPage : BasePage
<%@ Page Language="C#" MasterPageFile="~/Master.Master"
    AutoEventWireup="true"
    CodeBehind="Blog.aspx.cs"
    Inherits="FocusedGames.Blog" 
    Title="Focused Games - Blog" 
%>

If I go to BasePage.aspx, everything works as expected. However, whenever I goto ChildPage.aspx, it throws a null reference on MainLabel.
Advertisement
Well, I found out that when using a label it creates a span in the html which is illegal since it contains divs. So I went another route. I now have a div in the master file with a runat="server" tag so I can set the inner html from the code.

This topic is closed to new replies.

Advertisement