Title and UpdatePanel

6 posts, 0 answers
  1. Matthew
    Matthew avatar
    18 posts
    Member since:
    Mar 2009

    Posted 22 May 2009 Link to this post

    Hi, I wondered if you had a sample to help me out.

    I create docks dynamically. All content within each dock is contained within an UpdatePanel. Thus I can change the content in a partial postback without a browser repaint - nice (in fact it's the result of a drag-drop dfrom your tree control).

    However, I want to be able to change the title of a dock within a partial postback. Thus I want the title of the dock to be within an UpdatePanel so I can tell the AJAX framework to repaint it.

    Do you have a ready-made solution or sample?

    thanks

    Matt

  2. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 25 May 2009 Link to this post

    If you want to set a new text to the title you could handle RadDock's OnClientInitialize client side event and set RadDock's title via JavaScript, e.g.
    $find("RadDock1").set_title("newText");
    Another approach is to add UpdatePanels in ContentTemplate and TitleBarTemplate and add triggers to the UpdatePanels , e.g.
    ASPX:
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head id="Head1" runat="server">  
        <title></title>  
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" > 
        </asp:ScriptManager> 
        <div> 
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server">  
                     <telerik:RadDockZone ID="RadDockZone1" runat="server">  
                        <telerik:RadDock ID="RadDock1" runat="server">  
                            <TitlebarTemplate> 
                                <asp:UpdatePanel ID="UpdatePanelTitle" runat="server" > 
                                    <ContentTemplate> 
                                        <asp:Label ID="lblTitle" runat="server"></asp:Label> 
                                    </ContentTemplate> 
                                </asp:UpdatePanel> 
                            </TitlebarTemplate> 
                            <ContentTemplate> 
                                <asp:UpdatePanel ID="UpdatePanelContent" runat="server">  
                                    <ContentTemplate> 
                                        <asp:Label ID="lblContent" runat="server"></asp:Label>     
                                    </ContentTemplate> 
                                </asp:UpdatePanel> 
                            </ContentTemplate> 
                        </telerik:RadDock> 
                     </telerik:RadDockZone>    
         </telerik:RadDockLayout> 
         <asp:Button ID="Button1" runat="server" Text="Postback"/>   
         <asp:Label ID="Label1" runat="server" Text="aaa"></asp:Label>    
        
          </div> 
        </form> 
    </body> 
    </html> 
    Codebehind:
    protected override void OnInit(EventArgs e)  
        {  
            base.OnInit(e);  
             
            AsyncPostBackTrigger btnClickTrigger = new AsyncPostBackTrigger();  
            btnClickTrigger.ControlID = "Button1";  
            btnClickTrigger.EventName = "Click";  
            UpdatePanelContent.Triggers.Add(btnClickTrigger);  
            UpdatePanelTitle.Triggers.Add(btnClickTrigger);  
        }  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            Label1.Text = System.DateTime.Now.ToString();  
     
            ((Label)RadDock1.TitlebarContainer.FindControl("lblTitle")).Text = System.DateTime.Now.ToString();  
            ((Label)RadDock1.ContentContainer.FindControl("lblContent")).Text = System.DateTime.Now.ToString();  
        } 
  3. Matthew
    Matthew avatar
    18 posts
    Member since:
    Mar 2009

    Posted 03 Jun 2009 Link to this post

    If I use the html sample you've given won't I lose the controls in the title bar?
  4. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 04 Jun 2009 Link to this post

    The RadDock's commands will be there if you use TitleBar template.
    You can find an exmaple where the TitleBar template is used here:
    http://demos.telerik.com/aspnet-ajax/dock/examples/edittitle/defaultcs.aspx
  5. Golu
    Golu avatar
    41 posts
    Member since:
    Dec 2008

    Posted 30 Jul 2009 Link to this post

    Dear sir,
    I am creating dock dynamically then how can I create title template?
  6. Jim
    Jim avatar
    31 posts
    Member since:
    Jun 2009

    Posted 04 Aug 2009 Link to this post

    You can dynamically add Controls to the TitleBarContainer Controls collection in the following way:

    For an example if you have a RadDock in the .aspx
            <telerik:RadDockLayout ID="RadDockLayout1" runat="server"
                <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="300px" Width="300px"
                    <telerik:RadDock ID="RadDock1" runat="server" Width="300px" Title="RadDock-Title"
                        <ContentTemplate> 
                            <asp:Label ID="Label1" runat="server" Text="TextNotChanged"></asp:Label> 
                        </ContentTemplate> 
                    </telerik:RadDock> 
                </telerik:RadDockZone> 
            </telerik:RadDockLayout> 

    When the page initializes we can add a LinkButton control to its TitleBarContainer, and attach an event handler method to the LinkButton Click event:
    protected void Page_Init(object sender, EventArgs e) 
        LinkButton LinkButton1 = new LinkButton(); 
        LinkButton1.Text = "LinkButton Text"
     
        // attach an event handler to the Click event 
        LinkButton1.Click += new EventHandler(LinkButton_Click); 
     
        // add the LinkButton to the RadDock's TitleBar template 
        RadDock1.TitlebarContainer.Controls.Add(LinkButton1); 
     
     
    protected void LinkButton_Click(object sender, EventArgs e) 
        Label1.Text = DateTime.Now.ToString(); 


Back to Top