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

How to get the control raddock ID

3 Answers 88 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Karthik
Top achievements
Rank 1
Karthik asked on 05 Oct 2010, 12:27 PM
Hi all,

I am trying to load RadDock dynamically with controls on dock expand using AJAX. I have provided the code below the commented part is the problem. I am unable to get the control ID which raised the postback.

If possible provide me with the code to dynamically create the portal page with the ajaxified docks.
RadDock RadDock1 = new RadDock();
    RadAjaxPanel AjPanel = new RadAjaxPanel();
 
    RadDock RadDock2 = new RadDock();
    RadAjaxPanel AjPanel2 = new RadAjaxPanel();
    
    protected void Page_Init(object sender, EventArgs e)
    {
        Session["ExpandCtrlID"] = null;
 
        AjPanel.RenderMode = UpdatePanelRenderMode.Inline;
        RadDock1.ID = "RadDock1";
        DockExpandCollapseCommand ex1 = new DockExpandCollapseCommand();
 
        RadDock1.Commands.Add(ex1);
        RadDock1.Collapsed = true;
        RadDock1.Command += new DockCommandEventHandler(RadDock1_Command);
        RadDock1.ContentContainer.Controls.Add(AjPanel);
        RadDock1.CommandsAutoPostBack = true;
        RadDock1.OnClientCommand = "DockOnClientCommand";
        RadDockZone1.Controls.Add(RadDock1);
 
        AjPanel2.RenderMode = UpdatePanelRenderMode.Inline;
        RadDock2.ID = "RadDock2";
        RadDock2.Commands.Add(new DockExpandCollapseCommand());
        RadDock2.Collapsed = true;
        RadDock2.Command += new DockCommandEventHandler(RadDock2_Command);
        RadDock2.ContentContainer.Controls.Add(AjPanel2);
        RadDock2.CommandsAutoPostBack = true;
        RadDock2.OnClientCommand = "DockOnClientCommand";
        RadDockZone1.Controls.Add(RadDock2);
    }
 
 
    void RadDock2_Command(object sender, DockCommandEventArgs e)
    {
        string controlID = RadDock2.ClientID;
        LoadUserControlInDock(controlID);
    }
 
    void RadDock1_Command(object sender, DockCommandEventArgs e)
    {
        string controlID = RadDock1.ClientID;
        LoadUserControlInDock(controlID);       
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "";
        if (Page.IsPostBack)
        {
            if (ScriptManager1.IsInAsyncPostBack)
            {
                //RadDock dock;
                //dock = sender as RadDock;
                //string id = dock.ClientID.ToString();
                LoadUserControlInDock(id);
                Label1.Text = "Asynchronous";
            }
            else
            {
                Label1.Text = "Not Asynchronous";
            }
        }
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadDock1, AjPanel);
        }
 
    protected void LoadUserControlInDock(string contID)
    {
        Control c1 = new Control();
        c1 = this.LoadControl("WebUserControl.ascx");
 
        switch (contID)
        {
            case "RadDock1":
                AjPanel.Controls.Clear();
                AjPanel.Controls.Add(c1);
                Test.Value = "Loaded";
                break;
            case "RadDock2":
                AjPanel2.Controls.Clear();
                AjPanel2.Controls.Add(c1);
                Test.Value = "Loaded";
                break;
        }
    }
 

3 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 08 Oct 2010, 07:46 AM
Hello Karthik,

The Page_Load method is a handler, as its name suggests, for the Page.Load event, and it is raised by the page. This means that the sender is not the control that posted the page back to the server, but the Page itself.
For your specific scenario I would recommend using the RadDock's Command server-side event. I believe the following live demos will be of help:


Best wishes,
Pero
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
Karthik
Top achievements
Rank 1
answered on 08 Oct 2010, 10:38 AM
Hello Pero,

I have used the Rad Dock's Server side event in the example. When i make any Ajax requests inside the control it won't raise the command event handler, Due to this the control disappears. What should i do to solve this problem?

Thanks in Advance.
0
Accepted
Pero
Telerik team
answered on 12 Oct 2010, 02:53 PM
Hello Karthik,

The RadDock's Command server-side event is fired only when any of the RadDock's command buttons is pressed. It is not fired on every post back to the server.
When dynamically adding controls you should make sure they are created and added to the page on every postback. Basically once the control is added to the dock in Command event handler, you should recreate the control in some of the Page events, like Page.Init or Page.Load. My suggestion is to do this in Page.Init, so that the ViewState is loaded correctly for this control.

Greetings,
Pero
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
Tags
Dock
Asked by
Karthik
Top achievements
Rank 1
Answers by
Pero
Telerik team
Karthik
Top achievements
Rank 1
Share this question
or