Reputation: 188
I have a master page with couple ContentPlaceHolder
inside it and added some content page of this master page.
I would like to set Visible="False"
on one asp:Content
in some page but it's not working as I'm still able to view data of both asp:Content
controls.
Why?
Master page:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterBase.Master.cs" Inherits="MasterBase" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<!-- HEADER -->
<asp:ContentPlaceHolder ID="head" runat="server" />
<!-- CONTENT -->
<asp:ContentPlaceHolder ID="bodyContent" runat="server" />
<!-- FOOTER -->
...
</form>
</body>
</html>
Content Page
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server" Visible="False">
<!-- Some Data -->
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="bodyContent" runat="server">
<!-- Some Data -->
</asp:Content>
Upvotes: 1
Views: 3863
Reputation: 127
Try this
mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("Content1");
mpContentPlaceHolder.Visible=False;
Upvotes: 3