Problem with EditTitle RadDock

6 posts, 0 answers
  1. DAN
    DAN avatar
    2 posts
    Member since:
    Jun 2008

    Posted 10 Sep 2008 Link to this post

    Double Click Dock Title to rename it  Problem ... Text Box not focus
    This Problem for :
    RadControls for ASP.NET AJAX Q2 2008 SP1 (Version Number 2008.2.826)
    RadControls for ASP.NET AJAX Q2 2008 (Version Number 2008.2.723)
  2. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 11 Sep 2008 Link to this post

    Hello,

    The previous versions of the RadDock control used the drag and drop functionality which is provided by the ASP.Net Ajax framework. However, there were a number of performance as well as cross-browser problems with the MS implementation. In the official release of the control from Q2 2008 the drag/drop functionality has been replaced by a brand new improved (Telerik) implementation which addresses the previously existing problems. The new implementation, however, led to the problem you mention in the RadDock control and we are aware of it.

    For the moment, we have not received other requests for this feature - you are the first who is asking for it.
    Do you really use this functionality? Is it crucial for your scenario? If we receive other requests for this feature we can consider reworking the new drag/drop implementation in order to support it, however, for the moment we accept that this functionality is not used by our customers and therefore we think to remove this example at all.

    All the best,
    Sophy
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dimitri Troncquo
    Dimitri Troncquo avatar
    3 posts
    Member since:
    Apr 2008

    Posted 26 Nov 2008 Link to this post

    We need similar functionality for a dragable raddock with a textbox in its titlebar.
    I understand why the dragable scenario causes the textbox to lose focus, and have been trying to hack my way around this, but I'm simply wasting too much time doing this.
    It was fairly straightforward to implement a workaround in Firefox (just added an onclick event on the textbox which calls the focus() function on the textbox) but this solution does not work for IE (I tried all kinds of scenarios, including setting timeouts). The strange thing is calling the textbox focus() function on document load does work, so i don't really understand why it doesn't work with the textbox onclick (the function does get called, i tested it).

    Quite annoying...
  5. Petko
    Admin
    Petko avatar
    45 posts

    Posted 28 Nov 2008 Link to this post

    Hello Danny,

    I've prepared a small sample for you, that shows how to achieve the desired behavior.
    ASPX:

    <body> 
        <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
        <div> 
         <script type="text/javascript">  
               function set_focus()  
              {   
                var textbox = $get("<%= TextBox1.ClientID %>");  
                if(textbox)  
                {  
                    textbox.focus();  
                }  
               }  
         </script> 
           
            <telerik:raddocklayout runat="server" id="RadDockLayout1">  
                <telerik:raddockzone runat="server" id="RadDockZone1" Width="300" MinHeight="200" style="float:left;margin-right:15px;">  
                    <telerik:raddock runat="server" id="RadDock1" text="Static Dock" width="400">  
                        <titlebartemplate> 
                            <asp:updatepanel runat="server" id="UpdatePanel1">  
                                <contenttemplate> 
    <asp:linkbutton id="LinkButton2" runat="server" onclick="LinkButton1_Click" style="text-decoration: none;  
    color: Gray;" text="Initial text">  
                                    </asp:linkbutton> 
                                    <asp:textbox runat="server" id="TextBox1" width="200px" visible="false"></asp:textbox> 
                                    <asp:linkbutton runat="server" id="LinkButton1" onclick="LinkButton1_Click"><!-- No Text --></asp:linkbutton> 
                                </contenttemplate> 
                            </asp:updatepanel> 
                        </titlebartemplate> 
                    </telerik:raddock> 
                </telerik:raddockzone> 
            </telerik:raddocklayout> 
            <script type="text/javascript">  
            function enableDockDrag(enable)  
            {  
               var dock = $find("<%= RadDock1.ClientID%>");  
               if (enable)  
               {  
                    dock._initializeDrag();  
                    var textbox = $get("<%=TextBox1.ClientID%>");  
                   if(textbox)  
                   {      
                        $addHandler(textbox, "mousedown", function(e)  
                        {  
                          e.stopPropagation();  
                        });  
                   }  
              }  
              else dock._disposeDrag();  
            }  
              
            </script> 
        </div> 
        </form> 
    </body> 

    Code-behind:

    protected void LinkButton1_Click(object sender, EventArgs e)  
        {  
            if (TextBox1.Visible)  
            {  
                LinkButton2.Visible = true;  
                TextBox1.Visible = false;  
                LinkButton2.Text = TextBox1.Text;  
                LinkButton1.Text = "";  
                ScriptManager.RegisterStartupScript(this, this.GetType(), "enabledrag", "enableDockDrag(true);", true);  
            }  
            else  
            {  
                LinkButton2.Visible = false;  
                TextBox1.Visible = true;  
                TextBox1.Text = LinkButton2.Text;  
                LinkButton1.Text = "OK";  
                ScriptManager.RegisterStartupScript(this, this.GetType(), "enabledrag", "enableDockDrag(false);", true);  
                ScriptManager.RegisterStartupScript(this, this.GetType(), "setfocus", "set_focus();", true);  
            }  
        } 

    I used our online example for RadDock "EditTitle" and modified it by adding a script, that focuses the textbox on the client side, and ScriptManager.RegisterStartupScript on the server side, that execute the script.
    Hope this helps you.

    Greetings,
    Petko
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Yueming
    Yueming avatar
    10 posts
    Member since:
    Oct 2012

    Posted 24 Oct 2012 Link to this post

    I use RadDock. There is one textbox(txtSSN) in RadDock1. For some reason I don't use txtSSN.Focus(), this way works fine. But I can't set focus if I use JavaScrip. I don't know way?
    Thanks. 

    Here is my code

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          
            
            Dim sb As New System.Text.StringBuilder("")
            sb.Append("<script language='JavaScript'>")
            sb.Append("document.getElementById('" + txtSSN.ClientID + "').focus();<")
            sb.Append("/")
            sb.Append("script>")
            ClientScript.RegisterStartupScript(Me.GetType(), "FOCUS", sb.ToString)
           
        End Sub
  7. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 29 Oct 2012 Link to this post

    Hi Yueming,

    You should use the Sys.Application.load event to ensure that your code will be executed after all scripts have been loaded:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     
        Dim sb As New System.Text.StringBuilder("")
        sb.Append("<script language='JavaScript'>")
        sb.Append("Sys.Application.add_load(setFocus); function setFocus() {$get('" + txtSSN.ClientID + "').focus(); Sys.Application.remove_load(setFocus);}<")
        sb.Append("/")
        sb.Append("script>")
        ClientScript.RegisterStartupScript(Me.GetType(), "FOCUS", sb.ToString)
     
    End Sub


    Regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017