SharePoint Experts, Information Architects, Expert Witness

SICG provides a broad array of business and technology consulting from architecture to design to deployment of global systems with a focus on surfacing data in the enterprise. We focus on the "How", not just the possible. Contact me direct: david_sterling@sterling-consulting.com or call 704-873-8846 x704.

Search This Blog

Friday, October 3, 2008

JScript Error using SharePoint HtmlEditor Control

Just one of those "had the problem" and know others will...

When using the HtmlEditor in a web part, you may find that you start receiving JScript errors even though you a) may not have rendered the control and b) the code seems to execute fine all the way through the Render Event.

The problem is that the Control requires anchoring to the physical control on the page; if you define it in the OnLoad or CreateChildControls methods but DO NOT render the control, this situation will occur.

To get around this, you must render the control and Hide it using a Div as in:


writer.Write("
");
CreateHeaderEditorControl.RenderControl(writer);
writer.Write("
");

NOTE: Do not use Visible=false; the control is not rendered and you will get the same error.