Problem in MasterPage directives...

Hi!

When I insert a MasterPage directives in my sharepoint custom page I receive the below error.
Any help?

Regards,

Joseph

The referenced file '/12/Template/Layouts/ApplicantManagement.Web/MasterPages/default.master' is not allowed on this page.   at System.Web.UI.TemplateParser.ProcessError(String message) 
   at System.Web.UI.BaseTemplateParser.GetReferencedType(VirtualPath virtualPath, Boolean allowNoCompile) 
   at System.Web.UI.PageParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData) 
   at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective)

Open in new window

LVL 8
PagodNaUtakAsked:
Who is Participating?
 
puru1981Connect With a Mentor Commented:
you need to do this like below:

protected override void OnPreInit(EventArgs e)
{
    base.OnPreInit(e);

    SPWeb Web = SPContext.Current.Web;
    string strUrl =
        Web.ServerRelativeUrl + "/_catalogs/masterpage/default.master";

    this.MasterPageFile = strUrl;
}


http://msdn.microsoft.com/en-us/library/cc297200.aspx
0
 
puru1981Commented:
can you post your ASPX for the page
0
 
PagodNaUtakAuthor Commented:
Hi, Attached here is the ASPX File...
Default111.zip
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
puru1981Commented:
is this path exist in your folder structure
/12/Template/Layouts
0
 
PagodNaUtakAuthor Commented:
yes...
 
0
 
PagodNaUtakAuthor Commented:
Yes, it exist in the folder structure, and in fact I just browse it...
0
 
puru1981Commented:
try to remove the ~ sign from the masterpage path
0
 
PagodNaUtakAuthor Commented:
I been debugging the whole day, yet you found the answer rigth away... thanks...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.