Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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" %>
share|improve this question
add comment

4 Answers 4

up vote 6 down vote accepted

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" %>
share|improve this answer
    
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. –  Amadeo Gallardo Mar 8 '12 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? –  Amadeo Gallardo Mar 8 '12 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 Mar 8 '12 at 14:22
1  
'<%@ 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" %>' - I just tried this and it works fine. –  sssreddy Mar 8 '12 at 15:54
2  
DynamicMasterPageFile attribute is used for application pages. see msdn.microsoft.com/en-us/library/gg454789.aspx –  sssreddy Mar 8 '12 at 16:00
show 2 more comments

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.

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

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.

share|improve this answer
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. –  Amadeo Gallardo Mar 8 '12 at 13:41
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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