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

Set focus to RadInput within RadWindow ContentTamplate on load

4 Answers 268 Views
Input
This is a migrated thread and some comments may be shown as answers.
Bernhard Rosenfelder
Top achievements
Rank 1
Bernhard Rosenfelder asked on 04 Apr 2011, 06:06 PM
hi community,

does anyone know how to set the focus on a radinput within radwindow contenttemplate onload. i set VisibleOnPageLoad="true" at the radwindow. i have tried all the described methods on (http://demos.telerik.com/aspnet-ajax/input/examples/common/focus/defaultcs.aspx).

thanks
Bernhard

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Apr 2011, 09:17 AM
Hello Bernhard,


Try setting focus to TextBox in OnclientShow event of RadWindow and see whether it helps.

Sample code:
var obj;
function pageLoad() {
    obj = $find('<%= RadTextBox22.ClientID %>');
}
function OnWindowShow(sender, args) {
    setTimeout(" obj.focus();", 200);
}


And the mark-up is shown below:
<telerik:RadWindow VisibleOnPageLoad="true" OnClientShow="OnWindowShow" ID="RadWindow1"
    runat="server" Height="300px" Width="450px" Modal="true">
    <ContentTemplate>
        <div id="div1">
            <asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
            <telerik:RadTextBox ID="RadTextBox22" runat="server" Skin="Black">
            </telerik:RadTextBox>
        </div>
    </ContentTemplate>
</telerik:RadWindow>


Have a nice day.

Regards,
Princy.
0
Bernhard Rosenfelder
Top achievements
Rank 1
answered on 05 Apr 2011, 06:25 PM
hi princy,

with the code in your sample it is working well.

thank you!!

regards,
bernhard
0
mark baer
Top achievements
Rank 1
answered on 20 Apr 2011, 05:08 PM
I had this same problem.  I tried the code above but it did not work.  I changed it to the code below and was able to get it to work(for anyone else having this problem).

 

<P><body class="form" onload="pageLoad" ></P>
<P>    <form id="form1" runat="server" 
defaultfocus="txtUserName"><BR><telerik:RadScriptManager 
ID="RadScriptManager1" runat="server"><BR>    
</telerik:RadScriptManager><BR>    <telerik:RadWindow 
ID="RadWindow1" runat="server" VisibleOnPageLoad="true" Behaviors="None" 
Skin="WebBlue" Title="Login to Creative Affairs!" <BR>    
VisibleStatusbar="False" OnClientShow="OnWindowShow" Modal="true" Height="155px" 
Width="300px"     
><BR>        
<ContentTemplate><BR>            
<telerik:RadScriptBlock ID="RadScriptBlock1" 
runat="server"><BR>                
<script 
type="text/javascript"><BR>                    
var 
obj;<BR>                    
function pageLoad() 
{<BR>                        
obj = document.getElementById('<%= txtUserName.ClientID 
%>');<BR>                        
//alert(obj);<BR>                    
}<BR>                    
function OnWindowShow(sender, args) 
{<BR>                        
//obj = $find('<%= txtUserName.ClientID 
%>');<BR>                        
//alert(obj);<BR>                        
if (obj != null) 
{<BR>                            
setTimeout(" obj.focus();", 
300);<BR>                        
}<BR>                    
} </P>
<P>                
</script><BR>            
</telerik:RadScriptBlock></P>
0
Gowtham
Top achievements
Rank 1
answered on 07 May 2014, 02:49 PM
Hi,
      Princy thanks...working fine..
Tags
Input
Asked by
Bernhard Rosenfelder
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bernhard Rosenfelder
Top achievements
Rank 1
mark baer
Top achievements
Rank 1
Gowtham
Top achievements
Rank 1
Share this question
or