1. Creating a project
Create a Visual Studio project (this should generally be done only once for each instance of Sitecore).
To create the project:
- Open Visual Studio .NET.
- From the File menu select New Project.
- Select the language you would like to use (Sitecore internally uses C# exclusively).
Select New Project in Existing Folder.
- Enter a name for your project. Names should not begin with numbers or contain special characters.
Enter the address of the website hosting the project, typically http://localhost in development.
In Solution Explorer, press the Show All Files button.
Right-click on References and choose Add Reference.
Browse to the /bin/ folder of the project and select Sitecore.Kernel.
Right-click on /web.config and select Include In Project.
- Right-click on the /xsl/ directory and select Include in Project.
Open the /layouts/ directory, right-click on each Layout or Sublayout
and choose Include in Project.
Layouts typically do not contain code-behind; Sublayouts commonly contain code-behind. To be prompted to create a code behind, exclude a file from the project temporarily, then add it again.
- Optionally, open the /sitecore modules/ directory in Windows Explorer and create one or more folders as needed. Return to Visual Studio, refresh Solution Explorer and include these directories in the project.
Right-click on the name of the project in Solution Explorer and choose
Set Assembly Name and Default Namespace.
2. Add code-behind to layouts or sublayouts.
To add code-behind to a Layout:
Open the project in Microsoft® Visual Studio .NET.
Open Solution Explorer and navigate to the folder containing the Layout (usually /layouts).
If the Layout is already included in the project, right-click on it and exclude the Layout.
Right-click on the Layout and add it to the Project; Visual Studio will suggest that a code-behind be created.
3. Enable IntelliSense
NOTE: The following information does not apply to Visual Studio 2005. Microsoft changed the file format for IntelliSense in VS 2005. We do not currently have an IntelliSense source for Xml Controls and Layouts for Visual Studio 2005.
Perform the following steps to enable IntelliSense in Visual Studio when editing Xml Controls and Xml Layouts.
- Copy the following file:
from the Sitecore web root to the Visual Studio schema directory. The Visual Studio schema directory is usually:
c:\program files\Microsoft Visual Studio .NET 2003/Common7/Packages/Schemas/xml/
- In the Xml Control or Xml Layout file, make sure the following Namespace is included:
<?xml version="1.0" encoding="utf-8" ?>