This is a migrated thread and some comments may be shown as answers.
Cannot get RadComboBox to work with MOSS2007
7 Answers 154 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
markus
Top achievements
Rank 1
markus asked on 19 Apr 2007, 03:12 PM
Hello,

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

Sort by
0
surfer
Top achievements
Rank 1
answered on 19 Apr 2007, 03:20 PM

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">
    <script>
    var controlClientObject = <%= RadControl1.ClientID %>
    ...
    </script>
</head>

<body>
...
</body>

After:

<head runat=a?servera?>
</head>
<body>
    <script>
    var controlClientObject = <%= RadControl1.ClientID %>
    ...
    </script>
...
</body>
0
markus
Top achievements
Rank 1
answered on 19 Apr 2007, 03:31 PM
Hi surfer,

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
0
Mike
Top achievements
Rank 1
answered on 19 Apr 2007, 03:34 PM
Are you using client-side (javascript) code with rad ComboBox - typically, the <%= RadComboBox1.ClientID %> references required to get the client-side instance of the combobox (and placed in the <head> tag of the page) generate this type of problem.

You may also try setting the runat="server" property for the head tag as well - for example

<head runat="server">
0
markus
Top achievements
Rank 1
answered on 19 Apr 2007, 07:06 PM

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

0
markus
Top achievements
Rank 1
answered on 19 Apr 2007, 09:11 PM
found out what causes the problem: Telerik.RadComboboxUtils.RadControl.RegisterCssFile() is like this:

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 






0
markus
Top achievements
Rank 1
answered on 19 Apr 2007, 09:46 PM
Found out that Sharepoint's master pages do indeed use <head runat="server" /> and since  RegisterCssFile manipulates the header that's where the problem lies. ONly thing is - Sharepoint requires the head tag with runat="server" otherwise one can't use the <SharePoint:AspMenu> control. I must be missing something - after all this would mean that r.a.d.controls and MOSS can't be used together.

Regards,
  Markus

0
markus
Top achievements
Rank 1
answered on 20 Apr 2007, 05:32 PM
Finally found the real reason for the error - MagicAjax. We use it instead of MS' Ajax implementation for web parts and turns out it messes up Page.Header - the resulting HTML code contains two nested <head> sections.

Problem solved - thank you all for your help!
Tags
RadControls
Asked by
markus
Top achievements
Rank 1
Answers by
surfer
Top achievements
Rank 1
markus
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Share this question
or