views:

108

answers:

2

I want to make a drop down control, an HTML select/dropdown box with two specific values. I want to package it so that I can deploy it to any SharePoint 2010 server I want, for its generic. At this point, I am confused if this should be a Visual WebPart, or a Web Control (does this exist in SharePoint 2010, Web Controls?). I would like the person ultimately using it to be able to place the control anywhere they like, including a non-webpart zone. Any help it getting me going is appreciated...

A: 

First, it'll help to mention that a WebPart or a Visual WebPart is, at its heart, a Web Control.

A Visual Web Part combines in one a WebPart and a UserControl with a designer surface, which brings Web Part development into a realm comfortable to a lot of us old ASP.NET developers.

If you want your user to be able to place the control in places other than web part zones, they'll need tools. It is possible to do this in SharePoint Designer, provided you are willing to provide both the control and the training.

In general, it will require that you develop the component, call it MyControl, either as a bare-bones web control or as a web part. Provide to your users instructions for registering the control's namespace at the top of the page layout via an @Register directive like this:

<@ Register TagPrefix="customcontrols" Namespace="My.WebControls.Namespace" Assembly="My.Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0101010101010" %>

Then your user can add it to the page layout as they would an ASP.NET page:

<customcontrols:MyControl runat="server" />

For most users, this will be a hefty bite to chew; however, no one knows your people better than you, so you can decide whether this will do or whether developing a web part for use in web part zones is better.

kbrimington
Thanks...If I want to make a bare bones web control, is there a template in VS 2010 for it?
bmw0128
@bmw0128: I don't think so. Usually, when I'm making a web control, I'll just create a class and have it inherit `CompositeControl`. I found Miguel Castro's online tutorials on making composite controls very helpful.
kbrimington
There is a UserControl template for SP 2010 in VS 2010. It's the regular asp.net UserControl plus extra Register and Import directives for SharePoint. For a CustomControl, you can use Web's ASP.NET Server Control template within a SP 2010 project.
Rich Bennema
A: 

Mr Bennema, what is the UserControl template called?

Neil Sammut