This is a migrated thread and some comments may be shown as answers.

RadControls in UserControl - error

2 Answers 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
matt
Top achievements
Rank 1
matt asked on 01 Jul 2008, 03:59 PM
hello,

in my ASPX webforms i use UserControls for a header and footer. like so:

<body> 
 
    <form id="form1" runat="server"
 
        <Me:Header ID="myHeader" runat="server" /> 
 
        <h1>my page</h1> 
 
        <p>my content</p> 
 
        <Me:Footer ID="myFooter" runat="server" /> 
 
    </form> 
 
</body> 

...however, if in my UserControl i include a RadControl then I get this error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

why is this? i am not using javascript or codeblocks. tho perhaps the RadControls are, i dunno.


ASCX

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Header.ascx.cs" Inherits="AutomaticVehicleLocator.controls.nav.Header" %> 
<%@ Register TagPrefix="Telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
 
<div id="Header"
    <img id="imgLogo" src="/images/logo.gif" alt="NOPD Logo" width="59" height="56" runat="server" /> 
 
    <div id="userInfo"
        <asp:Label ID="lblUsername" runat="server" /><br /> 
        <href="" class="help" id="btnSubmit">Help</a> 
    </div> 
 
    <!-- THIS BREAKS PAGE --> 
    <Telerik:RadComboBox ID="rcbTest" runat="server"
        <Items> 
            <telerik:RadComboBoxItem Value="1" Text="one" /> 
        </Items> 
    </Telerik:RadComboBox> 
 
</div> 



thanks
matt

2 Answers, 1 is accepted

Sort by
0
matt
Top achievements
Rank 1
answered on 01 Jul 2008, 04:34 PM
ok after some more testing i discovered: this is not related to UserControls.

this snippit breaks:

<body onload="PageLoadRecordsIntialize();"
 
    <form id="form1" runat="server"
     
        <asp:ScriptManager ID="scriptManager" runat="server" /> 
         
        <div id="Header"
            <img id="imgLogo" src="/images/logo.gif" alt="NOPD Logo" width="59" height="56" runat="server" /> 
 
            <div id="userInfo"
                <asp:Label ID="lblUsername" runat="server" /><br /> 
                <href="#" class="help" id="lnkHelp">Help</a> 
            </div> 
            
            <!-- BROKEN: the below RadWindow breaks page rendering -->
            <Telerik:RadWindowManager ID="radWindowManager" VisibleOnPageLoad="false" runat="server"
                <Windows> 
                    <Telerik:RadWindow 
                        ID="rwHelp" 
                        OpenerElementId="lnkHelp"  
                        NavigateUrl="helpMain.aspx" 
                        Modal="true" 
                        Behavior="Move,Close,Resize" 
                        Width="600px" 
                        Height="500px" 
                        Runat="server" /> 
                </Windows> 
            </Telerik:RadWindowManager> 
             
        </div> 
 
        <p>content</p> 
 
    </form> 
 
</body> 

0
matt
Top achievements
Rank 1
answered on 01 Jul 2008, 05:24 PM
ok, i found the problem. it was because:

1) my <head> element had the runat="server" attribute

2) my <head> element contain codeblocks

...so i was able to resolve.

however, i dont understand why this error was only triggered when a RadControl was employed.

telerik, any clues?


thanks
matt
Tags
General Discussions
Asked by
matt
Top achievements
Rank 1
Answers by
matt
Top achievements
Rank 1
Share this question
or