May202010

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

Published by Pete Celliers at 5:29 PM under Errors

Solutions to the following error:

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

You get this error when you have no masterpage assigned to your web form

Options to consider (other than simply adding your masterpage statically):

 You can derive all your pages from a base page in the web config file:

    <system.web>
      <pages pageBaseType="BasePage" >

then create a class and declare it as follow:

    public class BasePage : System.Web.UI.Page { ....

with the following method in it:

    protected override void OnPreInit(EventArgs e)
    {
        string ThemeName = "Bitlink";
        //this should point to your masterpage:
        MasterPageFile = VirtualPathUtility.ToAbsolute(("~/")) + "Themes/" + ThemeName + "/Master.master";
        base.OnPreInit(e);
    }

this way all your pages would be assigned to a certain masterpage dynamically.

 



[KickIt] [Digg] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Post RSSRSS comment feed 1 Responses

Comments


Response by dating websites on 8/25/2010 7:02:39 AM

this is very informatic & knowelagable article........



Add comment




biuquote
  • Comment
  • Preview
Loading