Problem in Dock title bar template

2 posts, 0 answers
  1. Golu
    Golu avatar
    41 posts
    Member since:
    Dec 2008

    Posted 11 Sep 2009 Link to this post

        #region CreatedRadDockFromState  
        private RadDock CreateRadDockFromState(DockState state)  
        {  
            RadDock dock = new RadDock();  
            dock.ID = string.Format(state.UniqueName);  
            dock.ApplyState(state);  
            dock.CssClass = "RadDock";          
            string strDockID = string.Format(state.UniqueName);  
    }  
     private RadDock CreateRadDock()  
    {  
     RadDock dock = new RadDock();  
     dock.Title = "List Summary" 
      dock.TitlebarTemplate = new DockTitleTemplate();  
    }  
     
      class DockTitleTemplate : ITemplate  
        {  
            TextBox txt = new TextBox();  
            Button btn = new Button();  
            LinkButton lnk = new LinkButton();  
     
            public void InstantiateIn(Control container)  
            {  
                lnk.ID = "lnk1";  
                lnk.Text = "initial text";  
                lnk.Click+=new EventHandler(lnk_Click);  
                container.Controls.Add(lnk);  
     
                txt.ID = "txt1";  
                container.Controls.Add(txt);  
                txt.Visible = false;  
                
                btn.ID = "btn1";  
                btn.Click+=new EventHandler(btn_Click);  
                btn.Text = "ok";  
                btn.Visible = false;  
                container.Controls.Add(btn);  
            }  
            protected void lnk_Click(object sender, EventArgs e)  
            {  
                txt.Visible = true;  
                btn.Visible = true;  
            }  
            protected void btn_Click(object sender, EventArgs e)  
            {  
                txt.Visible = false;  
                btn.Visible = false;  
            }  
        } 
     private RadDock CreateRadDock()  
    {  
     RadDock dock = new RadDock();  
     dock.Title = "List Summary" 
      dock.TitlebarTemplate = new DockTitleTemplate();  
    }  
     
      class DockTitleTemplate : ITemplate  
        {  
            TextBox txt = new TextBox();  
            Button btn = new Button();  
            LinkButton lnk = new LinkButton();  
     
            public void InstantiateIn(Control container)  
            {  
                lnk.ID = "lnk1";  
                lnk.Text = "initial text";  
                lnk.Click+=new EventHandler(lnk_Click);  
                container.Controls.Add(lnk);  
     
                txt.ID = "txt1";  
                container.Controls.Add(txt);  
                txt.Visible = false;  
                
                btn.ID = "btn1";  
                btn.Click+=new EventHandler(btn_Click);  
                btn.Text = "ok";  
                btn.Visible = false;  
                container.Controls.Add(btn);  
            }  
            protected void lnk_Click(object sender, EventArgs e)  
            {  
                txt.Visible = true;  
                btn.Visible = true;  
            }  
            protected void btn_Click(object sender, EventArgs e)  
            {  
                txt.Visible = false;  
                btn.Visible = false;  
            }  
        } 
    Hello sir,
    I am creating docks dunamically and would apply title editable funcationality...
    I am sending you my code, in that I am not using any update panel...

    once a title is update then save in database....

    Once we created dock then set dock title which is already given , then after created link on titleBar template of dock's title that shows one textbox and one button...when click on that button save and show that update title in database.

    how can I apply this functioning...please reply me ASAP..

    thanks with regards

  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 16 Sep 2009 Link to this post

    Hello,

    As you can see in our online demo we disable the dragging (using a JavaScript method loaded from the server) of the RadDock while text is entered in the TextBox and again we enable it after the OK button is pressed. In order to disable/enable dragging of the RadDock while in "title-bar edit mode" you need to place the following JavaScript method in the .aspx:

    <script type="text/javascript"
        function enableDockDrag(enable, dockId, textboxId) 
        { 
            var dock = $find(dockId); 
            if (enable) 
            { 
                dock._initializeDrag(); 
                var textbox = $find(textboxId); 
                if (textbox) 
                { 
                    $addHandler(textbox, "mousedown"function(e) 
                    { 
                        e.stopPropagation(); 
                    }); 
                } 
            } 
            else dock._disposeDrag(); 
        } 
    </script> 

    and the following C# code in the code behind:
    public class DockTitleTemplate : ITemplate 
        TextBox txt = new TextBox(); 
        Button btn = new Button(); 
        LinkButton lnk = new LinkButton(); 
        RadDock dock; 
     
        public DockTitleTemplate(RadDock dock) 
        { 
            this.dock = dock; 
        } 
     
        public void InstantiateIn(Control container) 
        { 
            lnk.ID = "lnk1"
            lnk.Text = "initial text"
            lnk.Click += new EventHandler(lnk_Click); 
     
            txt.ID = "txt1"
            txt.Visible = false
     
            btn.ID = "btn1"
            btn.Click += new EventHandler(btn_Click); 
            btn.Text = "ok"
            btn.Visible = false
     
            container.Controls.Add(lnk); 
            container.Controls.Add(txt); 
            container.Controls.Add(btn); 
        } 
        protected void lnk_Click(object sender, EventArgs e) 
        { 
            txt.Text = lnk.Text; 
            txt.Visible = true
            btn.Visible = true
            lnk.Visible = false
     
            var script = String.Format("Sys.Application.add_load(function(){{enableDockDrag(false,'{0}','{1}');}})"this.dock.ClientID, txt.ClientID); 
            ScriptManager.RegisterStartupScript(dock.Page,dock.Page.GetType(),"disableDrag",script,true); 
             
        } 
        protected void btn_Click(object sender, EventArgs e) 
        { 
            lnk.Text = txt.Text; 
            txt.Visible = false
            btn.Visible = false
            lnk.Visible = true
     
            var script = String.Format("Sys.Application.add_load(function(){{enableDockDrag(true,'{0}','{1}');}})"this.dock.ClientID, txt.ClientID); 
            ScriptManager.RegisterStartupScript(dock.Page, dock.Page.GetType(), "enableDrag", script, true); 
             
        } 

    Please note that now you have to set the dock's TitleBarContainer using the following line:
    dock.TitlebarTemplate = new DockTitleTemplate(dock); 


    In addition, you can test the project attached to the thread, which is a modified version of the my portal online demo.

    Sincerely yours,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top