This is a migrated thread and some comments may be shown as answers.
RadDockLayout Error
11 Answers 131 Views
This is a migrated thread and some comments may be shown as answers.
Sandeep
Top achievements
Rank 1
Sandeep asked on 05 May 2009, 02:19 PM
Hello,

Actually I am creating RadDocks dynamically with links in it. But when I click on the link its not working and while the page is post back its throwing an error.
Please find the code below.

    protected void Page_Load(object sender, EventArgs e)
    {
        PageLayout();
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        Label4.Text = "Click";
    }

    private void PageLayout()
    {
        RadDockZone Zone1 = new RadDockZone();
        RadDockZone Zone2 = new RadDockZone();
        Zone1.BackColor = System.Drawing.Color.White;
        Zone1.MinHeight = new Unit("10px");
        Zone1.Width = new Unit("200px");
        Zone1.BorderStyle = BorderStyle.None;
        Zone1.Style.Add(HtmlTextWriterStyle.Position, "absolute");
        Zone1.Style.Add(HtmlTextWriterStyle.Left, "5px");
        Zone2.BackColor = System.Drawing.Color.White;
        Zone2.MinHeight = new Unit("10px");
        Zone2.Width = new Unit("200px");
        Zone2.BorderStyle = BorderStyle.None;
        Zone2.Style.Add(HtmlTextWriterStyle.Position, "absolute");
        Zone2.Style.Add(HtmlTextWriterStyle.Left, "210px");

        Layout2TableAdapter Layout2Adapter = new Layout2TableAdapter();
        int Dock_Count = Layout2Adapter.GetSubGroup(1, "UB").Rows.Count;

        RadDock[] Docks = new RadDock[Dock_Count];

        for (int i = 0; i < Dock_Count; i++)
        {
            Docks[i] = new RadDock();
            Docks[i].Width = new Unit("485px");
            Docks[i].Skin = "Telerik";
            Docks[i].DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.ExpandCollapse;
            Docks[i].DockMode = DockMode.Docked;
            Docks[i].Title = Layout2Adapter.GetSubGroup(1, "UB").Rows[i][0].ToString();
            Dock_Layout(Docks[i], "UB");
            if (i % 2 == 0) Zone1.Controls.Add(Docks[i]);
            else Zone2.Controls.Add(Docks[i]);
        }

        Global.DockLayout.Controls.Add(Zone1);
        Global.DockLayout.Controls.Add(Zone2);
        Panel1.Controls.Add(Global.DockLayout);
    }

    private void Dock_Layout(RadDock Dock, string PageViewID)
    {
        Layout3TableAdapter Layout3Adapter = new Layout3TableAdapter();
        ReportTableAdapter ReportAdapter = new ReportTableAdapter();
        QueriesTableAdapter QueryAdapter = new QueriesTableAdapter();
        int Report_Count = Convert.ToInt32(QueryAdapter.ReportCount(1, "UB", Dock.Title));

        if (Report_Count > 0)
        {
            Label[] Labels = new Label[Report_Count];

            int RID = 0;
            string Dock_Height = "";
            string Link_Top = "";
            string Label_Top = "";

            for (int j = 0; j < Report_Count; j++)
            {
                RID = Convert.ToInt32(Layout3Adapter.GetReport(1, "UB", Dock.Title).Rows[j][0]);
                Dock_Height = (j * 60 + 90) + "px";
                Link_Top = (j * 55 + 10) + "px";
                Label_Top = (j * 55 + 25) + "px";

                Dock.Height = new Unit(Dock_Height);

                Global.newLink.ID = "NewLink";
                Global.newLink.Font.Underline = false;
                Global.newLink.Click += new EventHandler(LinkButton2_Click);
                Global.newLink.Style.Add(HtmlTextWriterStyle.Position, "absolute");
                Global.newLink.Style.Add(HtmlTextWriterStyle.Left, "5px");
                Global.newLink.Text = (j + 1) + ". " + ReportAdapter.GetDataByRID(RID).Rows[0][1].ToString();
                Global.newLink.Style.Add(HtmlTextWriterStyle.Top, Link_Top);
                Dock.ContentContainer.Controls.Add(Global.newLink);

                Labels[j] = new Label();
                Labels[j].Text = ReportAdapter.GetDataByRID(RID).Rows[0][2].ToString();
                Labels[j].Font.Italic = true;
                Labels[j].Style.Add(HtmlTextWriterStyle.Position, "absolute");
                Labels[j].Style.Add(HtmlTextWriterStyle.Left, "20px");
                Labels[j].Style.Add(HtmlTextWriterStyle.Top, Label_Top);
                Dock.ContentContainer.Controls.Add(Labels[j]);
            }
        }
    }

And I have declared the link and RadDockLayout globally.
    public static LinkButton newLink = new LinkButton();
    public static RadDockLayout DockLayout = new RadDockLayout();

And please find the error below.

Server Error in '/MyWeb' Application.

Script controls may not be registered after PreRender.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Script controls may not be registered after PreRender.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[InvalidOperationException: Script controls may not be registered after PreRender.]   System.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +155059   System.Web.UI.ScriptManager.RegisterScriptControl(TScriptControl scriptControl) +66   Telerik.Web.UI.RadWebControl.RegisterScriptControl() +29   Telerik.Web.UI.RadWebControl.OnPreRender(EventArgs e) +22   Telerik.Web.UI.RadDockZone.OnPreRender(EventArgs e) +185   System.Web.UI.Control.PreRenderRecursiveInternal() +80   System.Web.UI.Control.AddedControl(Control control, Int32 index) +8681381   System.Web.UI.ControlCollection.Add(Control child) +80   _Default.PageLayout() +1043   _Default.Page_Load(Object sender, EventArgs e) +166   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35   System.Web.UI.Control.OnLoad(EventArgs e) +99   System.Web.UI.Control.LoadRecursive() +50   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


I am working on this error for more than a month now. I would be greatful if you could tell me some solution for this.
Thanks in advance.

Regards,
Sandeep Devagiri

11 Answers, 1 is accepted

Sort by
0
Accepted
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 05 May 2009, 02:50 PM
The problem is that you declared the RadDockLayout as a static, e.g.
public static RadDockLayout DockLayout = new RadDockLayout();
if you remove static everything should be fine, e.g.
public RadDockLayout DockLayout = new RadDockLayout();
0
Sandeep
Top achievements
Rank 1
answered on 06 May 2009, 01:38 PM
Thank You.

Now I have removed static and declared the RadDockLayout inside the same code and not as a global object.
But now when I click on the link page is going to postback and the dock is disappearing. And even then link click event is also not working.
But when I added the RadDockLayout in the page nd just create the docks and the content in the dock dynamically it's working fine. Can you please tell me a solution for it.
Actually my aim was to capture some data when I click on the link like the text of the link and moce to someother page. If I use PostBackUrl property of the LinkButton it is going to that particular page but the Link event is not working.

Regards,
Sandeep Devagiri.
0
Sandeep
Top achievements
Rank 1
answered on 06 May 2009, 01:54 PM
Please find the code below.

    protected void Page_Load(object sender, EventArgs e)
    {
        UserTableAdapter UserAdapter = new UserTableAdapter();
        Label2.Text = UserAdapter.GetDataByUID(Global.UID).Rows[0][6].ToString();
        if (!Page.IsPostBack)
        {
            CreateTabs();
        }
    }

    protected void newLink_Click(object sender, EventArgs e)
    {
        Label2.Text = "Click";
    }

    private void CreateTabs()
    {
        Layout1TableAdapter Layout1Adapter = new Layout1TableAdapter();
        int Tab_Count = Layout1Adapter.GetGroupByUID(Global.UID).Rows.Count;

        RadTab[] Tabs = new RadTab[Tab_Count];

        for (int i = 0; i < Tab_Count; i++)
        {
            Tabs[i] = new RadTab();
            Tabs[i].Text = Layout1Adapter.GetGroupByUID(Global.UID).Rows[i][0].ToString();
            RadTabStrip1.Tabs.Add(Tabs[i]);
            AddPageView(Tabs[i].Text);
            PageLayout(RadMultiPage1.FindPageViewByID(Tabs[i].Text), Tabs[i].Text);
        }
    }

    protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
    {
        PageLayout(RadMultiPage1.FindPageViewByID(e.Tab.Text), e.Tab.Text);
    }

    private void AddPageView(string pageViewID)
    {
        RadPageView pageView = new RadPageView();
        pageView.ID = pageViewID;
        pageView.Width = new Unit("1020px");
        RadMultiPage1.PageViews.Add(pageView);
    }

    private void PageLayout(RadPageView PageView, string pageViewID)
    {
        RadDockLayout DockLayout = new RadDockLayout();

        RadDockZone Zone1 = new RadDockZone();
        RadDockZone Zone2 = new RadDockZone();
        Zone1.BackColor = System.Drawing.Color.White;
        Zone1.MinHeight = new Unit("10px");
        Zone1.Width = new Unit("485px");
        Zone1.BorderStyle = BorderStyle.None;
        Zone1.Style.Add(HtmlTextWriterStyle.Position, "absolute");
        Zone1.Style.Add(HtmlTextWriterStyle.Left, "5px");
        Zone2.BackColor = System.Drawing.Color.White;
        Zone2.MinHeight = new Unit("10px");
        Zone2.Width = new Unit("485px");
        Zone2.BorderStyle = BorderStyle.None;
        Zone2.Style.Add(HtmlTextWriterStyle.Position, "absolute");
        Zone2.Style.Add(HtmlTextWriterStyle.Left, "505px");

        Layout2TableAdapter Layout2Adapter = new Layout2TableAdapter();
        int Dock_Count = Layout2Adapter.GetSubGroup(Global.UID, pageViewID).Rows.Count;

        RadDock[] Docks = new RadDock[Dock_Count];

        for (int i = 0; i < Dock_Count; i++)
        {
            Docks[i] = new RadDock();
            Docks[i].Width = new Unit("485px");
            Docks[i].Skin = "Telerik";
            Docks[i].DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.ExpandCollapse;
            Docks[i].DockMode = DockMode.Docked;
            Docks[i].Title = Layout2Adapter.GetSubGroup(Global.UID, pageViewID).Rows[i][0].ToString();
            Dock_Layout(Docks[i], pageViewID);
            if (i % 2 == 0) Zone1.Controls.Add(Docks[i]);
            else Zone2.Controls.Add(Docks[i]);
        }

        DockLayout.Controls.Add(Zone1);
        DockLayout.Controls.Add(Zone2);
        PageView.Controls.Add(DockLayout);
    }

    private void Dock_Layout(RadDock Dock, string PageViewID)
    {
        Layout3TableAdapter Layout3Adapter = new Layout3TableAdapter();
        ReportTableAdapter ReportAdapter = new ReportTableAdapter();
        QueriesTableAdapter QueryAdapter = new QueriesTableAdapter();
        int Report_Count = Convert.ToInt32(QueryAdapter.ReportCount(Global.UID, PageViewID, Dock.Title));
        
        if (Report_Count > 0)
        {
            Label[] Labels = new Label[Report_Count];
            LinkButton[] Links = new LinkButton[Report_Count];

            int RID = 0;
            string Dock_Height = "";
            string Link_Top = "";
            string Label_Top = "";
            
            for (int j = 0; j < Report_Count; j++)
            {
                RID = Convert.ToInt32(Layout3Adapter.GetReport(Global.UID, PageViewID, Dock.Title).Rows[j][0]);
                Dock_Height = (j * 60 + 90) + "px";
                Link_Top = (j * 55 + 10) + "px";
                Label_Top = (j * 55 + 25) + "px";
            
                Dock.Height = new Unit(Dock_Height);

                Links[j] = new LinkButton();
                Links[j].ID = "Link" + j;
                Links[j].Font.Underline = false;
                Links[j].Click += new EventHandler(newLink_Click);
                Links[j].Style.Add(HtmlTextWriterStyle.Position, "absolute");
                Links[j].Style.Add(HtmlTextWriterStyle.Left, "5px");
                Links[j].Text = (j + 1) + ". " + ReportAdapter.GetDataByRID(RID).Rows[0][1].ToString();
                Links[j].Style.Add(HtmlTextWriterStyle.Top, Link_Top);
                Dock.ContentContainer.Controls.Add(Links[j]);

                AjaxSetting AS = new AjaxSetting(Links[j].ID);
                AjaxUpdatedControl AUC = new AjaxUpdatedControl("Label2", "RadAjaxLoadingPanel1");
                AS.UpdatedControls.Add(AUC);
                RadAjaxManager1.AjaxSettings.Add(AS);
                
                Labels[j] = new Label();
                Labels[j].Text = ReportAdapter.GetDataByRID(RID).Rows[0][2].ToString();
                Labels[j].Font.Italic = true;
                Labels[j].Style.Add(HtmlTextWriterStyle.Position, "absolute");
                Labels[j].Style.Add(HtmlTextWriterStyle.Left, "20px");
                Labels[j].Style.Add(HtmlTextWriterStyle.Top, Label_Top);
                Dock.ContentContainer.Controls.Add(Labels[j]);
            }
        }
    }

0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 07 May 2009, 09:40 AM
"If you want to create RadDock(RadDockZones or RadDockLayout) controls dynamically you should do it in the Init event of the page, in order to allow the RadDockLayout to automatically manage their positions. You could create RadDock controls in other events, but you should recreate them in Init when the next postback or AJAX request occurs."
You should recreate their content too.
A simple example which illustrates how to create RadDocks dynamically is available here:
http://demos.telerik.com/aspnet-ajax/dock/examples/dynamicdocks/defaultcs.aspx
0
Frank
Top achievements
Rank 1
answered on 13 Jun 2009, 12:58 AM
Why are you using postback and code-behind examples in the RadControls in ASP.NET MVC forum?

Is it actually possible to use RadDock in MVC?

Frank
0
Frank
Top achievements
Rank 1
answered on 13 Jun 2009, 04:54 AM
I'm back to report that I WAS able to successfully use RadDock, RadDockLayout and RadDockZones in an MVC viewpage, including a RadDock with a RadGrid in it populated through the MVC controller.

Frank
0
Harsh Verma
Top achievements
Rank 1
answered on 03 Nov 2009, 05:35 AM
hi
   You have to create dynamic dock from Page_init event . Not from Page_load.
0
Kyle Pike
Top achievements
Rank 1
answered on 20 Jan 2011, 10:02 PM
Frank: I am about to embark on an upgrade to an ASP.NET site to MVC that uses RadDock currently. any tips/gotchas/advice/code samples?

Telerik Team: any chance of RadDock for MVC in the future?
0
Georgi Krustev
Telerik team
answered on 21 Jan 2011, 10:02 AM
Hello Kyle,

 
We have logged your request to our products backlog list for further investigation and consideration. Depending on the users interest we will decide whether to include this component in our future roadmap

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sean
Top achievements
Rank 2
answered on 16 Jun 2011, 11:05 PM
For what it's worth, I am about to do this, as well, and would love any advice I could get..
0
Atanas Korchev
Telerik team
answered on 17 Jun 2011, 07:24 AM
Hello Sean,

 I am afraid there is no docking component available in Telerik Extensions for ASP.NET MVC. Your only option is to try and integrate RadDock for ASP.NET Ajax in your ASP.NET MVC application.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Sandeep
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Sandeep
Top achievements
Rank 1
Frank
Top achievements
Rank 1
Harsh Verma
Top achievements
Rank 1
Kyle Pike
Top achievements
Rank 1
Georgi Krustev
Telerik team
Sean
Top achievements
Rank 2
Atanas Korchev
Telerik team
Share this question
or