On Load Rad Treeview in UserControl Used with Master page gives error.

4 posts, 1 answers
  1. Aayam
    Aayam avatar
    19 posts
    Member since:
    Dec 2007

    Posted 12 Nov 2008 Link to this post


    Hi,

    I am sure many of us aware of  this error :

    System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).    
    at System.Web.UI.ControlCollection.Add(Control child)    
    at Telerik.Web.SkinRegistrar.RegisterCssReference(Page _page, Control _control, String _url)

    My case is i have a master page used as template.
    Now there is another page that has an user control in it which has the rad treeview in it.
    I am using the javascript for rad treeview with on load functionality using web service.

    To narrow down the problem i have just added a rad treeview with rad script manager to the user control
    This user control is placed in an aspx page which has a master page set for it.
    now While trying to access this page i am getting the same error.
    Can anyone help me in this respect.
    I need it urgently.
    Thanks for your help in advance.

    Ragards,
    Aayam Singh
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 12 Nov 2008 Link to this post

    Hi Aayam,

    Please wrap your javascript code with RadScriptBlock and let us know if that helps.

    Greetings,
    Veselin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Aayam
    Aayam avatar
    19 posts
    Member since:
    Dec 2007

    Posted 13 Nov 2008 Link to this post

    Hi,

    Thanks for reply.

    I have tried encapsulating the javascript within RadScriptBlock as well as RadCodeBlock.
    But both of them are not working and i am receiving the same error.
    In my javacript i have used : "var tree = $find("<%= rtvBrands.ClientID %>");"   to get the all then nodes for my tree.
    As i can see that article you pointed me was explaining this issue clearly.

    To explain more i have a Rad Treeview on the page with RadScriptManager.
    The first level nodes are only populated when page load for the first time.
    Then on expanding any node web service is being used to fetch the child nodes.
    The javascript are present on Check and toggle client events of Rad Treeview but they don't contain any sever tag as above.
    One particular Javascript function that creates an XML Document with data regarding all the nodes in brand treeview.
    For this function i need all the nodes available to us and read there check status, hence i have to use the above server <% %> block
    to get hold of Rad Treeview.
    But even after commenting this code in javascript my code breaks with same error.
    I have also tried to pass hardcoded clientId from Rad Treeview and run it but same error.

    I am not persisting the on load nodes of Rad Treeview and there is not post back for any of the nodes for radtreeview.
    Is there any other way i can resolve this problem and avoid this error?
    One more thing i have migrated my project from .Net 1.1 to .Net 3.5 and using all the updated libraries of latest version.

    Regards,
    Aayam Singh

  4. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Nov 2008 Link to this post

    Hi Aayam,

    You can also try moving your code block out of the head tag - inside the body tag for example. Also commenting server side expressions with JavaScript comments will not work. You should use the server-side comments syntax - <%-- something --%>

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top