Wednesday, October 26, 2011

Add custom controls to SharePoint Designer 2010

Haven't posted in a week or so.  So decided it was time to add something.  Lots of idea bouncing while I have been attending a training course on SharePoint Designer.

A question came up during class which was, "How do I add custom controls into SharePoint Designer that I can drag-and-drop like the controls already there?  For example, the ASP.NET controls.".

Here is the answer...

You will need to first copy your DLL and namespace to the SafeControls section of the 'web.config' file.  This will make your control available to SharePoint Designer.  However, an extra step is needed to make the control visible inside the GUI.

You will need to add an attribute to your class file.  Just above your class definition.  The attribute is:

[ToolboxData("<{0}:SomeNewControl runat=\"server\" />"), ToolboxItemFilter("Foo")]

Again, this goes above your class definition.  That is it.  You should now see your custom control inside SharePoint Designer under 'Server Controls'.  And it should work just like the others (drag-and-drop).

No comments:

Post a Comment