I'm trying to use rad controls with MOSS 2007 but can't find installation instructions for it. I have developed a user control with RadComboBox that works fine in ASP.NET 2.0 when embedded in a master page.
Now when I deploy this user control to MOSS it throws the following error message:
[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
System.Web.UI.ControlCollection.Add(Control child) +2060559
Telerik.RadComboboxUtils.RadControl.RegisterCssFile(String path) +192
Telerik.RadComboboxUtils.RadControl.RenderRuntimeSkin() +64
Telerik.RadComboboxUtils.RadControl.Page_PreRenderComplete(Object sender, EventArgs e) +10
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +2012676
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1566
I assume the error is caused by RadControl not finding a CSS file or something similar. Can you help with this? We are currently evaluating rad controls vs. NetAdvantage.
Regards,Markus
7 Answers, 1 is accepted
If you receive exceptions such as:
System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
you need to move the javascript code block outside of the head tag. For example:
Before:
<head runat="server"> |
After:
<head runat=a?servera?> |
Thanks for your response. That was also my first assumption but all my CSJS code is embedded in the user control together with the combo box. So the exception must be thrown by something else unless MOSS or rad controls move CSJS code into the header tag.
Regards,
Markus
You may also try setting the runat="server" property for the head tag as well - for example
<head runat="server">
Hello Mike,
No, I do not use CSJS in the header - at least not intentionally.
I was able to create a simple test case for my problem with rad controls and MOSS 2007:
1) download and install SmartPart v1.1 from http://www.gotdotnet.com/workspaces/workspace.aspx?id=6cfaabc8-db4d-41c3-8a88-3f974a7d0abe - you can find the link under Releases in the lower right hand page area.
2) create a user control RadControl.ascx with the following content:
<%@ Control Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="radC" %>
<radC:RadComboBox ID="RadComboBox1" runat="server" SkinsPath="~/RadControls/ComboBox/Skins" Width="150px">
<Items>
<radC:RadComboBoxItem runat="server" Text="RadComboBoxItem1"></radC:RadComboBoxItem>
<radC:RadComboBoxItem runat="server" Text="RadComboBoxItem2"></radC:RadComboBoxItem>
</Items>
</radC:RadComboBox>
3) create a folder "usercontrols" in c:\Inetpub\wwwroot (or wherever your MOSS is installed) and copy RadControl.ascx into it.
4) copy RadCombobox.Net2.dll into c:\Inetpub\wwwroot\bin
5) Enable the Smartpart feature and create a Smartpart web part. Configure it to read the RadControl.ascx.
Step 5 is where I get the error message.
Regards,
Markus
private void RegisterCssFile(string path)
{
if (!IsClientScriptBlockRegistered(path))
{
RegisterClientScriptBlock(path);
if (!this.IsCssPathRegistered(path))
{
HtmlLink child = new HtmlLink();
child.Attributes["type"] = "text/css";
child.Attributes["rel"] = "stylesheet";
child.Attributes["href"] = path;
this.Page.Header.Controls.Add(child);
}
}
}
How can I set IsClientScriptBlockRegistered to true for the given CSS path?
Markus
Regards,
Markus
Problem solved - thank you all for your help!