Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
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."
 
<%@ 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 3-Sep-12 3:11am
Edited 3-Sep-12 3:27am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi ,
It seems you are missing MasterPageFile="" it should have the director for Master page file
Best Regards
M.Mitwalli
  Permalink  
Comments
Manas Bhardwaj at 4-Sep-12 16:16pm
   
5!
Mohamed Mitwalli at 5-Sep-12 0:48am
   
Thanks manas :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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[^]
  Permalink  
Comments
Manas Bhardwaj at 4-Sep-12 16:17pm
   
good 5!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 324
1 Kornfeld Eliyahu Peter 160
2 Nelek 115
3 Gihan Liyanage 99
4 Sergey Alexandrovich Kryukov 94
0 Zubair MCA 55
1 OriginalGriff 55
2 sankarsan parida 55
3 harshavardhan12345678 45
4 Sandeep Londhe 45


Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100