The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

  • Advertisements

Add .Net User Controls to SharePoint

Posted by Clayton James on May 25, 2009

I have been developing inside SharePoint for a while now and while things are getting easier with tools I think this process for developing User Controls inside SharePoint gives me a lot of control.

  1. I have a Graphical User Interface
  2. I have a separate project to build and test outside of SharePoint
  3. I can easily update and view my project html and binary code

Currently this process doesn’t create me any SharePoint Solution files to deploy across environments. I think to achieve this I will need to create a VS 2008 SharePoint Project…but so far these projects seem to add weight and time that I don’t want at the moment…while I am developing.

  1. Create a VS2008 web project
  2. In IIS create an IIS Application under your SharePoint web site that has a path to your VS2008 web project created above. This helps for updating content
  3. In your VS2008 project create some user controls and test that they function
  4. In VS2008 project properties under the Build Events tab point the Post Build events text box and add a copy statement to copy your .dlls and .pdbs to your SharePoint web sites bin directory. This will deploy a new .dll every time you build your VS2008 project. I had problems when I put the VS2008 project .dll into the GAC…it only worked when I put it into the SharePoint’s web sites bin directory
  5. Update your master page with CSS references if your VS2008 project contains a style sheet.
  6. In SPD in your Page Layout add a Register directive to register your user control
    “<%@ Register Src=”~/UI/UserControls/JobGoals.ascx” TagPrefix=”uc1″ TagName=”JobGoals” %>”
    Update the SharePoint web site web.config file
            <add src=”~/UI/UserControls/MyAttributes.ascx” tagPrefix=”uc1″ tagName=”MyAttributes”/>
            <add src=”~/UI/UserControls/JobGoals.ascx” tagPrefix=”uc1″ tagName=”JobGoals” />
  7. Add the User Control to the Page Layout
    <uc1:JobGoals ID=”JobGoals1″ runat=”server” />
  8. Update the SharePoinnt web sites web.config file
    <SafeControl Src=”~/UI/*”  IncludeSubFolders=”True” Safe=”True” AllowRemoteDesigner=”True” />
  9. Restart IIS, navigate to a page that uses the page layout and you should see your User Control

Because we created a IIS Application under our SharePoint web site and mapped our VS2008 projects .dll output path to our SharePoints web site, updates are extremely simple.

  1. .ascx changes:                modify, save in VS2008 and refresh sharepoint browser
  2. .ascx.cs changes:          modify, save, build  in VS2008 and refresh sharepoint browser

4 Responses to “Add .Net User Controls to SharePoint”

  1. Mate, I”ve done a similar thing over one SharePointDevWiki.com too:
    http://www.sharepointdevwiki.com/display/public/SharePoint+Development+with+Visual+Design+User+Controls with code snippets and ui, be interestd in your feedback? Think we’re using exactly the same approach…

  2. JXL65 said

    But the Taliban needs to be decimated. ,

  3. lecchen said

    как влияет протеин на потенцию – народное лечение импотенции, лечение импотенции народными средствами, импотенция методы лечения, способы лечения импотенции, препараты. Сайт lechenie-impotencii.ru

  4. masutyf said

    чат мастурбаторов Флешлайт – мастурбатор для мужчин cobra libre, мастурбатор, великий мастурбатор, великом мастурбаторе, мастурбатор видео, сибирский мастурбатор, мастурбаторы. Сайт fleshlayt.ru

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: