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

trying to set focus in a radwindow, in a user control

1 Answer 282 Views
Window
This is a migrated thread and some comments may be shown as answers.
David Avery
Top achievements
Rank 1
David Avery asked on 27 Jan 2011, 06:13 PM
Hey guys

Trying to set focus to a specific control in a radwindow content template.  I have the following in my Onclientshow (taken from another thread).  Thanks!

<script type="text/javascript">
    function OnClientShow(sender, args) {
        var pnum = $get('<%# rwDialog.FindControl("radnMvPropNo").ClientID %>');
        pnum.focus();
    }
</script>

The problem is that at run time, the findcontrol server side block is turning up ''
<script type="text/javascript">
 function OnClientShow(sender, args) {
 var pnum = $get('');
 pnum.focus();}
</script>

Becase this is in a user control, I suspect I need to do something different to find the control:
"WctlShippingCart_rwDialog_C_radnMvCustNo_wrapper" is what is has become.


The content layout is as follows:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="True"
    Modal="True" Behavior="Default" InitialBehavior="None">
    <Windows>
        <telerik:RadWindow runat="Server" ID="rwDialog" Modal="true" Title="Move Selected Properties"
            OnClientShow="OnClientShow" AutoSize="True" Behavior="Close, Move" Behaviors="Close, Move"
            VisibleStatusbar="False">
            <ContentTemplate>
                <table width="220px">
                    <tr>
                        <td style="width: 12%">
                        </td>
                        <td style="width: 32%">
                            Customer #
                        </td>
                        <td style="width: 1%">
                        </td>
                        <td style="width: 1%">
                        </td>
                        <td style="width: 7%">
                        </td>
                        <td style="width: 32%">
                            Property #
                        </td>
                        <td style="width: 12%">
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <telerik:RadNumericTextBox runat="Server" ID="radnMvCustNo" Width="50px" Culture="English (United States)"
                                Skin="Vista" MaxLength="4" MaxValue="9999" MinValue="1000">
                                <NumberFormat DecimalDigits="0" GroupSeparator="" />
                            </telerik:RadNumericTextBox>
                        </td>
                        <td>
                        </td>
                        <td style="text-align: center">
                            -
                        </td>
                        <td>
                        </td>
                        <td>
                            <telerik:RadNumericTextBox runat="Server" ID="radnMvPropNo" Width="50px" Skin="Vista"
                                Culture="English (United States)" MaxValue="9999" MinValue="1000" MaxLength="4">
                                <NumberFormat DecimalDigits="0" GroupSeparator="" />
                            </telerik:RadNumericTextBox>
                        </td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td colspan="5" style="text-align: center">
                            <br />
                            <asp:Button runat="Server" ID="btnMoveOK" Text="Move" />
                              
                            <asp:Button runat="Server" ID="btnMoveCancel" Text="Cancel" />
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 01 Feb 2011, 10:31 AM
Hi David Avery,

 I prepared for you the following code which does what you need:


<%@ Page Language="C#" %>
  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body id="body">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script type="text/javascript">
        function OnClientShow(sender, args)
        {
  
            setTimeout(function ()
            {
                var pnum = $find('<%= rwDialog.ContentContainer.FindControl("radnMvPropNo").ClientID%>');
                pnum.focus();
            }, 0);
        }
     
    </script>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="True"
        Modal="True" Behavior="Default" InitialBehavior="None">
        <Windows>
            <telerik:RadWindow runat="Server" ID="rwDialog" Modal="true" Title="Move Selected Properties"
                OnClientShow="OnClientShow" AutoSize="True" Behavior="Close, Move" Behaviors="Close, Move"
                VisibleStatusbar="False" VisibleOnPageLoad="true">
                <ContentTemplate>
                    <table width="220px">
                        <tr>
                            <td style="width: 12%">
                            </td>
                            <td style="width: 32%">
                                Customer #
                            </td>
                            <td style="width: 1%">
                            </td>
                            <td style="width: 1%">
                            </td>
                            <td style="width: 7%">
                            </td>
                            <td style="width: 32%">
                                Property #
                            </td>
                            <td style="width: 12%">
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <telerik:RadNumericTextBox runat="Server" ID="radnMvCustNo" Width="50px" Culture="English (United States)"
                                    Skin="Vista" MaxLength="4" MaxValue="9999" MinValue="1000">
                                    <NumberFormat DecimalDigits="0" GroupSeparator="" />
                                </telerik:RadNumericTextBox>
                            </td>
                            <td>
                            </td>
                            <td style="text-align: center">
                                -
                            </td>
                            <td>
                            </td>
                            <td>
                                <telerik:RadNumericTextBox runat="Server" ID="radnMvPropNo" Width="50px" Skin="Vista"
                                    Culture="English (United States)" MaxValue="9999" MinValue="1000" MaxLength="4">
                                    <NumberFormat DecimalDigits="0" GroupSeparator="" />
                                </telerik:RadNumericTextBox>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td colspan="5" style="text-align: center">
                                <br />
                                <asp:Button runat="Server" ID="btnMoveOK" Text="Move" />
                                <asp:Button runat="Server" ID="btnMoveCancel" Text="Cancel" />
                            </td>
                            <td>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    </form>
</body>
</html>


I hope that my reply is helpful, let me know how it goes.

Regards,
Svetlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Window
Asked by
David Avery
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or