treeview dynamically

4 posts, 0 answers
  1. fg
    fg avatar
    5 posts
    Member since:
    May 2011

    Posted 11 Aug 2011 Link to this post

    hi

    whenever i try to add radtreeview from codebehind i got the error 'script controls cannot be registered after prerender'
    how to solve this.

    thanks
    Rashmi
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2011 Link to this post

    Hello Rashmi,

    Here is the sample code that I tried to create TreeView dynamically which worked as expected.

    aspx:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        </div>
        </form>
    </body>
    </html>

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
            if (!IsPostBack)
            {
                RadTreeView testTree = new RadTreeView();
                testTree.ID = "testTree";
                RadTreeNode node1 = new RadTreeNode();
                node1.Text = "Inbox";
                testTree.Nodes.Add(node1);     
                RadTreeNode node2 = new RadTreeNode();
                node2.Text = "Drafts";
                testTree.Nodes.Add(node2);       
               this.Controls.Add(testTree);
            }
    }

    Thanks,
    Princy.
  3. fg
    fg avatar
    5 posts
    Member since:
    May 2011

    Posted 11 Aug 2011 Link to this post

    hi

    Thanks for your reply. Below is my problem.Please check this
    ScriptManager is already there

    I have  RadCombobox with RadTreeView like below

    <telerik:RadComboBox    ID="ExportContactsClassMenu"  RunAt="server"   Skin="Vista" Width="195" Enabled="false"   >                             
                                     
                                                        <ItemTemplate>
                                                            <telerik:RadTreeView
                                                                RunAt="server"
                                                                ID="ExportContactsClassMenu_EmbeddedTreeView"
                                                                OnClientNodeClicking="ExportContactsClassMenu_OnClientNodeClicking">
                                                                <DataBindings>
                                                                  
                                                                </DataBindings>
                                                            </telerik:RadTreeView>
                                                        </ItemTemplate>
                                                        <Items>
                                                            <telerik:RadComboBoxItem Text="" />
                                                        </Items>
                                                    </telerik:RadComboBox> 
    I have a datatable with Runat=server in callback content. I have to add this RadCombobox to datatable row cell dynamically in codebehind

     HtmlTableCell cell0 = new HtmlTableCell();
            cell0.Controls.Add(ExportContactsClassMenu);//ExportContactsClassMenu - radcombobox id
            row.Cells.Add(cell0);
            RulesTable.Rows.Add(row);//datatable id
    when i am trying to do above thing i am getting the following error
    'script controls cannot be registered after prerender'.

    thanks
    Rashmi
  4. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 11 Aug 2011 Link to this post

    Hello Fg,

    Please take a look at the following forum thread:

    http://www.telerik.com/community/forums/aspnet-ajax/docking/script-controls-may-not-be-registered-after-prerender.aspx

    Kind regards,
    Helen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top