FreeTextBox: How to fix “The type or namespace name ‘Toolbar’ could not be found”

I’m working on a Visual Studio 2005 ASP.NET project which makes use of FreeTextBox to provide rich text editing capability. My code sets up the toolbar programmatically but, despite following the installation instructions to the letter (including setting up the FTB TagPrefix), my code was failing to compile with The type or namespace name ‘Toolbar’ could not be found on the following line of code:

Toolbar ftbTools = new Toolbar();

I initially fixed this by adding the FreeTextBoxControls prefix:

FreeTextBoxControls.Toolbar ftbTools =
                             new FreeTextBoxControls.Toolbar();

But then my code fell over with a similar error on the very next line:

ftbTools.Items.Add(new ParagraphMenu());

Not wanting to have to add the FreeTextBoxControls prefix to this and my other 18 Add statements, I instead added the following using statement to my code file:

using FreeTextBoxControls;

Job done!

How to set SharePoint page title programmatically

I’ve spent some time today trying to figure out how to set the title of a SharePoint page from my own code. As blogger Michael Becker rightly points out, you can’t simply set Page.Title.

The correct solution, as provided by Michael, is illustrated in this example C# code:

// Get a reference to the appropriate Content Placeholder
ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder) 
                       Page.Master.FindControl("PlaceHolderPageTitle");

// Clear out anything that SharePoint might have put in it already
contentPlaceHolder.Controls.Clear();

// Put your content in
LiteralControl literalControl = new LiteralControl();
literalControl.Text = "Your text goes here";
contentPlaceHolder.Controls.Add(literalControl);

Happily this even works when you “cheat” by hosting an ASP.NET user control within a SmartPart, as opposed to creating a bona fide Web Part.

Deploy ASP.NET web user controls on SharePoint using SmartPart

Today I’ve been playing with Return of SmartPart 1.3,  a shim which allows you to create SharePoint 2007 web parts using Web User Controls (ASCX files) created by Visual Studio/Visual Web Developer.

This is probably the least painful way for C#/VB.NET developers to delve into web part building without having to worry too much about the intricacies of the SharePoint platform.

Complete with setup wizard, comprehensive user guide and sample user controls, it’s a snap to get running, although you will need access to your SharePoint server both to install the SmartPart and any custom user controls. It also optionally supports AJAX controls, after installing Microsoft’s ASP.NET AJAX extensions.

There’s no need to use strong naming or even compile your controls – just drop the .ascx (and .ascx.cs/.vb, if necessary) files into your usercontrols directory and you’re good to go.