4

When editing a Page Layout in Visual Studio 2010 the 'asp' prefix is not recognized.
For example:

<asp:Content contentplaceholderid="PlaceHolderBreadCrumb" runat="server">

Has 'asp' green-underlined stating "Unrecognized tag prefix or device filter 'asp'".

Among other annoyances, there's no intellisense for controls, no auto format of code, etc.

I already "forced" the editor to use "Web Form Editor", but still doesn't work. These are my references:

<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Register TagPrefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="CustomTag_0" Namespace="Microsoft.Office.Server.WebControls.FieldTypes" Assembly="Microsoft.Office.Server.UserProfiles, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="CustomTag_1" Namespace="Northridge.SharePoint.Common" Assembly="Northridge.SP2010.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82b873716895b724" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

4 Answers 4

6

Force the editor to open in "Web Form Editor" as you mentioned and add "MasterPageFile "attribute like below, you should be able to get intellisense.

<%@ Page Language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" MasterPageFile=""%>

EDIT:

Don't know about the implications when deploying with that master page set, but it seems to be working just fine.

<%@ Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePo‌​int.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" MasterPageFile="~masterurl/default.master" %>
7
  • Interesting. It didn't work with MasterPageFile="". But if I put something like MasterPageFile="nonsense" it works. Of course, it blows out when navigating to a page using the page layout, so it's not a final solution, but seems like there's something related to the MasterPage reference. Commented Mar 8, 2012 at 13:48
  • Well, now I changed it to MasterPageFile="~masterurl/default.master" (read that in a default Application Page stub), and it seems to be working now. I don't know the implications on the SP UI though, maybe it'll force the page to use that master? Commented Mar 8, 2012 at 13:52
  • 1
    ~masterurl/default.master is the dynamic token and will be replaced at runtime with site master page. Using MasterPageFile attr you can override the default master page of your site and use your custom master page But specifying the dynamic token you are forcing it to use site master page (which is same as not specifying the masterpage attribute). [Ref: msdn.microsoft.com/en-us/library/…
    – sssreddy
    Commented Mar 8, 2012 at 14:22
  • 1
    '<%@ Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" MasterPageFile="~masterurl/default.master" %>' - I just tried this and it works fine.
    – sssreddy
    Commented Mar 8, 2012 at 15:54
  • 2
    DynamicMasterPageFile attribute is used for application pages. see msdn.microsoft.com/en-us/library/gg454789.aspx
    – sssreddy
    Commented Mar 8, 2012 at 16:00
3

Have you tried restarting VS2010, and redeploying your solution to the site?

Visual Studio is a bit new at this editing ASPX pages that reference external assemblies not in the same project (nevermind not being a standard 'Web Application' Project Type).

I get this all the time too and just live with it, sometimes it goes away and I get IntelliSense back, others I jsut have to fly blind and hope stuff works.

Let's just hope Visual Studio 11 fixes these bugs.

4
  • 1
    Yeah, not to talk about the <asp:content> (lowercase) that causes page layouts to be unghosted. Sigh. Commented Mar 7, 2012 at 22:18
  • It didn't fix it! Commented Jun 27, 2013 at 14:04
  • Does VS2013 fix it? I tried but it kept blue screening on me :(
    – James Love
    Commented Jun 27, 2013 at 14:11
  • Didn't try 2013 yet, let's hope so! Commented Jun 28, 2013 at 15:46
0

Usually I always edit my pagelayouts in SharePoint Designer, as it has the IntelliSense needed to do so. At least for the use of SharePoint controls. Then I copy paste it all to my VS and add the ASP.net controls if I need 'em. Works rather well.

1
  • 1
    It's an option, but I rather do all my work in the same IDE. In theory, it should work, since it's plain good old times asp.net development. Commented Mar 8, 2012 at 13:41
0

I ran into this problem today, using the DynamicMasterPageFile attribute with the tokenization ~masterurl/custom.master in application pages. I tried to fix it for two hours and found out the root cause is VS being unable to find the master page.

For me, the issue was that the farm was inaccessible (SQL was stopped). Restarting SQL and an IIS reset fixed this in my case. This may not be the fix every time, but resolving farm accessibility is the key here.

Edit:

An additional, potential cause of this error is if the target "Site URL" property of the VS project is invalid in the Properties pane. For instance, if the alternate access mappings of the target site have changed or if the targeted web application is no longer available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.