Ivan Martinović
Ivan Martinović

Reputation: 11

Master Page won't display its content on a Web Forms

I am creating a Web Forms project with a Master Page. However, when I put a label on the master page (or any other control or html element) it does not display it on the web form. How can I fix this problem?

MasterPage:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="RWA.MasterPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form" runat="server">
<div>
<asp:ContentPlaceHolder ID="MasterPagePlaceHolder" runat="server">
<asp:Label ID="NameLabel" runat="server" Text="Label"></asp:Label> 
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

Web Form:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" 
AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="RWA.Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MasterPagePlaceHolder" 
runat="server">
</asp:Content>

Upvotes: 1

Views: 197

Answers (1)

Ivan Martinović
Ivan Martinović

Reputation: 11

Fixed it, only needed to remove the control from the content placeholder

Upvotes: 0

Related Questions