Custom web site (aspx pages) in sharepoint

4 03 2009

Here, you could find the steps to customize aspx pages with code behind files.
Here is how to do it:

  1. Install Microsoft Visual Studio – update to support web application projects.
  2. Install the Visual Studio 2005 Web Application Projects extension. Don’t download Microsoft Visual Studio 2005 Team Suite Service Pack 1.
  3. START – File – New Project – ASP.NET Web Application – Name it “WebProject1″
  4. Add reference to Microsoft.Sharepoint
  5. Create your .aspx pages with code behind files.
  6. Once you are done, build the solution with the strong names (recommended).
  7. Now, create a folder in your Sharepoint site using SPD 2007. For eg. http://<server name>/myFolder
  8. Copy your pages (not code files) in that folder using SPD 2007.
  9. 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>
  10. 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>
  11. 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
  12. Open the web.config file for the SharePoint Web Application E.g. C:\Inetpub\wwwroot\wss\VirtualDirectories\80\web.config
  13. Add the following line to the SafeControls section (change to suit your assembly and namespace etc…) <SafeControl Assembly=" WebProject1" Namespace=" WebProject1" TypeName="*" />
  14. Change the <trust level="WSS_Minimal" originUrl="" />
    line to<trust level="WSS_Medium" originUrl="" />
  15. Open your site in SharePoint Designer and drag and drop your myPage.aspx page into a folder in your site.
  16. 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.





Custom workflow using C#

4 03 2009

Pre-requisites

  1. VS 2005 Extensions for WSS 3.0
  2. VS 2005 Extensions for Workflow Foundation

Steps

  1. File ->New Project -> Visual C# -> Sharepoint -> Sharepoint Server Sequential Workflow Library.
  2. And draw the diagram for Sharepoint Sequential Workflow. For every new “Create Task with ContentType ID” Item, you need to modify the properties like “TaskID” and “ContentType ID”. “TaskID” should be different for different tasks, which can be created using Tools-> New GUID and “ContentTypeID” should be mapped with one of the lists/tasks in the Sharepoint server.
  3. Whenever you are placing different components like onTaskChange, onTaskComplete, make sure you are mapping with the correct TaskID of CreateTask.
  4. Code behind the different items can be done easily with the help of e-surfing.
  5. In project properties, you need to sign the assembly under ‘Signing’ tab.
  6. In Workflow.xml, modify the attributes as followsworkflow
  7. In Features.xml, it should look likefeatures
  8. Build the solution. Now you are done.







Follow

Get every new post delivered to your Inbox.