Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm using master pages in that i'm designing my page with in Content Place Holder only. But I got this error

"Content controls are allowed only in content page that references a master page."

ASP.NET
<%@ Page Title="" Language="C#" MasterPageFile="~/Master/MasterPage.master" AutoEventWireup="true" CodeFile="ExcelToSqlDB.aspx.cs" Inherits="DMS_ExcelToSqlDB" %>
<%@ Register TagPrefix="rad" Namespace="Telerik.WebControls" Assembly="RadCalendar.NET2" %>
<%@ Register Src="../CommonControls/MsgBox.ascx" TagName="MsgBox" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<p>
        <uc1:MsgBox ID="Msgbox1"  runat="server" />
    </p>
    <p>
        <table cellpadding="3" cellspacing="1" style="width: 75%" align="center">
            <tr>
                <td align="center" bgcolor="Black" style="width: 363px">
                     </td>
                <td align="center" bgcolor="Black">
                     </td>
            </tr>
            <tr>
                <td style="width: 363px" align="right">
                    Browse:</td>
                <td>
                    <asp:FileUpload ID="fupExcel" runat="server" />
 
                    <asp:Button ID="btnGetExcel" runat="server" Text="Get Excel Sheet" />
                </td>
            </tr>
            <tr>
                <td style="width: 363px" align="right">
                    <asp:Label ID="lblsheet" runat="server" Text="Sheet Name : "></asp:Label>
                <td>
                    <asp:DropDownList ID="ddlSheet" runat="server" AutoPostBack="True" 
                        Visible="False">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td style="width: 363px">
                     </td>
                <td>
                    <asp:Button ID="btnFetch" runat="server" Text="Fetch" Visible="False" />
         
                    <asp:Button ID="btnUpload" runat="server" Text="Upload" Visible="False" />
                </td>
            </tr>
        </table>
        <br />
    </p>
    <table style="width: 100%">
        <tr>
            <td>
        <asp:GridView ID="grvMaterial" runat="server" AllowPaging="True"
        OnRowDataBound="grvMaterial_RowDataBound" HorizontalAlign="Center"
                     EmptyDataText="No/Invalid Records Found Pls. Check" 
            BackColor="White" GridLines="Vertical" BorderColor="#999999" BorderStyle="Solid" 
                    BorderWidth="1px" CellPadding="3" ForeColor="Black" PageSize="8">
            <AlternatingRowStyle BackColor="#CCCCCC" />
            <Columns>
                     <asp:TemplateField HeaderText="Serial number">
                    <ItemTemplate>
                        <asp:Label ID="lblSerial" runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                     </Columns>
            <FooterStyle BackColor="#CCCCCC" />
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
            
          
        </asp:GridView>
            </td>
        </tr>
    </table>
    <p>
    </p>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderPageTitle" Runat="Server">
</asp:Content>


can any one help me where i'm wrong


Thanks in advance...
Posted
Updated 3-Sep-12 3:27am
v3

Hi ,
It seems you are missing MasterPageFile="" it should have the director for Master page file
Best Regards
M.Mitwalli
 
Share this answer
 
Comments
Manas Bhardwaj 4-Sep-12 16:16pm    
5!
Mohamed Mitwalli 5-Sep-12 0:48am    
Thanks manas :)
As error clearly states: "Content controls are allowed only in content page that references a master page.", if you try to use Content control on a page then it has to refer a master page.

Generally, when you define something in content control, .NET runtime tries to fit in that content in a defined master page placeholder to form complete page. If you just provide content control then it will not understand where exactly to use it.

Read some basics about Master page here:
MSDN: ASP.NET Master Pages[^]
ASPNET: ASP.NET Master Pages Tutorials[^]
ASP.NET 2.0 Master Pages[^]
 
Share this answer
 
Comments
Manas Bhardwaj 4-Sep-12 16:17pm    
good 5!
Make sure there are no errors in your web.config file.
It sometimes happens when you are referencing an assembly in web.config and it does not exists in the bin folder
e.g. AjaxToolKit.dll
 
Share this answer
 
It seem my error, the solution one is correct for me. After I checked again it work.

Thank.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900