The full error details reads like:
Content controls are allowed only in content page that references a master page. at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection)
at System.Web.UI.Page.get_Master()
at System.Web.UI.Page.ApplyMasterPage()
at System.Web.UI.Page.PerformPreInit()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Resolution: It is so that you have to use sharepoint website's master page if you have to include the sharepoint chrome. I forgot to set the master page in my custom aspx page deployed to 12 hive. That's why I got the error. If you want to display it that way, put code similar to what I have written below in order to set master page dynamically for your custom page:
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;
SPWeb _web;
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
//Using current SharePoint site's masterpage
this._web = SPControl.GetContextWeb(Context);
this.MasterPageFile = _web.MasterUrl;
}
Very good! Save my time, upgraded my knowledge
ReplyDeleteGlad it helped you.
Delete