Here, you could find the steps to customize aspx pages with code behind files.
Here is how to do it:
- Install Microsoft Visual Studio – update to support web application projects.
- Install the Visual Studio 2005 Web Application Projects extension. Don’t download Microsoft Visual Studio 2005 Team Suite Service Pack 1.
- START – File – New Project – ASP.NET Web Application – Name it “WebProject1″
- Add reference to Microsoft.Sharepoint
- Create your .aspx pages with code behind files.
- Once you are done, build the solution with the strong names (recommended).
- Now, create a folder in your Sharepoint site using SPD 2007. For eg. http://<server name>/myFolder
- Copy your pages (not code files) in that folder using SPD 2007.
- In each page, your code looks like:
<%@ Page Language="C#" CodeBehind="myPage.aspx.cs" Inherits=" WebProject1.myPage" Title="My Sample Page" %>
<% Meta……….%>
<HTML>
<HEAD><TITLE>…………………..</TITLE></HEAD>
<BODY><FORM>…………………
…………………..[Your Code]…………….
……………………………………………
</FORM></BODY>
</HTML>
- Change the code into
<%@ Page Language="C#" MasterPageFile="~masterurl/default.master" CodeBehind="myPage.aspx.cs" Inherits=" WebProject1.myPage" Title="My Sample Page" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>
<asp:Content ID="Content5" ContentPlaceHolderID="PlaceHolderMain" runat="server">
………………………….[Your code]…………………….
</asp:Content>
- Copy the dlls from your project bin folder to \BIN folder of our SharePoint Web application. E.g. C:\Inetpub\wwwroot\wss\VirtualDirectories\ 80\bin
- Open the web.config file for the SharePoint Web Application E.g. C:\Inetpub\wwwroot\wss\VirtualDirectories\80\web.config
- Add the following line to the SafeControls section (change to suit your assembly and namespace etc…)
<SafeControl Assembly=" WebProject1" Namespace=" WebProject1" TypeName="*" /> - Change the
<trust level="WSS_Minimal" originUrl="" />
line to<trust level="WSS_Medium" originUrl="" /> - Open your site in SharePoint Designer and drag and drop your myPage.aspx page into a folder in your site.
- Browse to your page E.g. http:///myFolder/myPages.aspx
Note: If you want to debug your code once it is running inside SharePoint then all you need to do is attach the Visual Studio debugger to the correct w3wp.exe process (Debug -> Attach to process), set your break points and then hit your page in a browser.

