7
votes

I'm using Visual Studio 2010 to develop a SharePoint Server 2010 solution. Part of this includes custom Page Layouts, but when editing them, intellisense is completely broken, since Visual Studio doesn't appear to know how to handle them. Here's what I've done:

  1. Created a new blank solution
  2. Right-clicked on the solution and created a new "Empty SharePoint Project"
  3. Right-clicked on the project and created a new "Module"
  4. Renamed sample.txt to MyPageLayout.aspx or created a new ASPX Web Form

At this point, intellisense for the new Page Layout is broken. It gets even worse with tools like ReSharper installed. Also, things like "Format Document" will break the Page Layout (by for example changing asp:Content to asp:content)

What I've tried to get intellisense working:

  1. Added a Web.config from a standard Web Application Project to the root of the SharePoint Project - made no difference.
  2. Added the ProjectGuid for a Web Application Project to the SharePoint project file - broke the project.

Is there any way to get intellisense, and the rest of the support Visual Studio can offer for Web Forms, available when developing SharePoint 2010 Page Layouts?

4
Are you on a 64-bit machine? A co-worker has mentioned that SharePoint intellisense was broken on his 64 bit machine. Don't know if there's a fix though.Rikalous

4 Answers

1
votes

I have followed your post to some extent.

Using VS2010 (On an x64 machine)

  1. Create a blank SharePoint solution. (this properly combines your #1 & #2)
  2. Add a module (in SharePoint a module is like a folder or resource container)
  3. added a new class to the module (intellisense present)
  4. Added a new webpart to the module (intellisense present)
  5. added a user control to the project designer works and (intellisense present)

I believe that you should consider creating true server or visual web parts. This will have a harder learning curve but will pay with dividends in the future. You will be able to package and deploy your solution again or to another server/farm. Aspx pages can be added and manipulated by the dreaded SharePoint designer. In 2010 the theory is that those designer mods can be packaged and deployed.

I work in this environment every day and the best advice I can give is to embrace the SP object model and do 'it' the sharepoint way. Don't try to force SP to be something its not. :)

Here is the C# viewHere is the markup view

0
votes

This is probably not the solution you are looking for but it's the best thing I found for SharePoint development.

In your solution, create 2 projects :

1 SharePoint Project (empty or not)

1 ASP.NET web application project

Develop all your UI (aspx pages, ascx controls, etc.) in your ASP.NET project and create post-build steps that will copy the pages and controls to the appropriate folders in your SharePoint solution.

That way, you will benefit from all the features of web development in visual studio and it will be very easy to deploy as well. It is a bit of a time investment at first, but it is well worth it if you have any considerable amount of logic to implement in your aspx pages.

This blog post documents what you need to do.

0
votes

you can add an intellsense to pagelayouts by closing the page and simply reopen it from file->openfile->your file page layout path

-1
votes

Or you can directly "Right Click" on the file you want to open from the Solution explorer and then select "Open" : you'll get the Intellisense !