If you have implemented WSS or MOSS solutions, chances are that you have been asked to add some application-like functionality to the Sharepoint offer. This can be accomplished in several ways, but the one I have to meet my requests is to deliver a Web User Control (WUC) that will be loaded by a Sharepoint Webpart.

This way, you can develop you WUC anywhere (no need for WSS or MOSS installed) and later on encapsulate the call to the control in the Webpart.

To simplify the development process, I highly recoment the use of the Smartpart ( a webpart that has the ability to load Web User Controls and display them). For this you will need to create a folder in you WSS/MOSS web site called “UserControls”, where you should put all the WUC you will use. I don’t usually develop the WUC directly in this folder. It is usually best to develop the WUC in a Web Site test project and when all the complexity of the control is implemented I deal with the minor adjustments needed to make it work in the Sharepoint environment. The main advantage I see in this process is a simpler debug process as sometimes the errors in WSS/Moss are not very explicit.

Here is a basic method list I currently use:

In Visual Studio, I create a test web site with a folder called “UserControls”.

I add a WebUserControl to the UserControls folder and add the WUC to the /default.aspx page, so I can see test the progresses I am making

Develop all the logic of the WUC

In Sharepoint Central Administration, I create a new Web Application and a new site collection with the Blank Site template (ust for integration testing purposes)

Configure the smartpart and select the WUC from the list. If your list is empty, then there is a problem with your smartpart installation or WUC placement. Refer to the smartpart documentation to try and solve the problem

For you to fully understand the steps above, some experience in WSS/MOSS is required. Drop me a comment if you need more detailed steps..

This will put your WUC in Sharepoint. Usually you have some issues to deal with before all is up and running. I will try to enumerate some of the things that I had to fight against:

Query strings for WUC internal database connection: this held my breath for some time. After my WUC was up and running in my aspx test page, I imported it as described above and a sharepoint error page with the message “Trusted Connection can’t be used”. After some digging I found some posts on the subject and apparently this only happens if you use integrated windows authentication in the connection string (I can’t confirm this as I haven’t tested it). SQL Authentication was out of the question, and I had some databounded gridviews, select boxes, etc, so this had to work. The solution was (thanks to Miguel Barros for the help) to manually build the SqlDataSource objects and assign them to the controls. this required the creation of the OnInit method inside the .cs file.

MultiView control can’t be used in a WUC inside a webpart. Instead I used Panel control.

Exception management: this is crucial as some (yes some, that is how detailed I can go on this) cause the “Unexpected error” page and that’s it.

Debug, debug, debug. Use Attach to Process in Visual Studio to attach to the w3wp.exe process (several are usually running, so attach to all of them). This will allow your code to be debugged.

You may need to create your own webpart for loading the WUC. I’ll try to post a simple formula for doing so.

Hope this helped. I know there is not a lot of detail, but drop me a line if you need more detail or code samples and I’ll upgrade the post.

Due to the complexity of the envolved procedure, the Office team is releasing a highly recomended guidance plan for the upgrade procedure. It is called “Planning and Deploying Service Pack 1 for Microsoft Office SharePoint Server 2007 in a Multi-server Environment” and you can find it here: http://go.microsoft.com/fwlink/?LinkID=105621&clcid=0×409.

UPDATE 2007-12-19Yesterday I did a first attempt to install the WSS SP1, but the process didn’t go as expected. Installation failed and no rollback was performed, so I was left with a quite unstable system. I was very pressed for time, so no post mortem analisys was made to determin the exact causes of the problem. Will do so ASAP. Nevertheless be advised and DO Backup before you begin the upgrade process.