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

set focus to textbox in modal tooltip

1 Answer 47 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Kevin Farmer
Top achievements
Rank 1
Kevin Farmer asked on 01 Jul 2010, 10:10 PM
I have a modal tooltip and tried the javascript found here in the forum to set focus to a radTextbox and was unable to make it work.

Here is the HTML markup:

<

 

body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadScriptBlock ID="rsb" runat="server">
<script type ="text/javascript">
function rttPromptShow(sender, eventArgs) {

 

setTimeout(

function() {
var txt = $get("<%=txtTest.ClientID %>");
try {
  if (txt)
    txt.focus();

 

 

}

 

catch (e) { };

}, 500);

}

 

</script>
</telerik:RadScriptBlock>
<div>
<asp:Button ID="btnTeset" runat="server" Text="Show Tool Tip" />
<telerik:RadToolTip ID="rttPrompt" runat="server" Modal="true"
                               Position="Center" OnClientShow="rttPromptShow"
                               ShowEvent="FromCode" HideEvent="FromCode" Width="300px" Height="150px">
<telerik:RadTextBox ID="txtTest" runat="server" Text="Test">
</telerik:RadTextBox>
</telerik:RadToolTip>
</div>
</form>

</

 

body>

and here is the code behind:

 

 

Protected Sub btnTeset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTeset.Click
   Call rttPrompt.Show()

 

 

End Sub

I would also like the text in the text box to be selected.

Any help would be greatly appreciated.

Kevin


 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 07 Jul 2010, 10:27 AM
Hi Kevin Farmer,

Basically your code is correct but you shoudl reference teh client object of the RadTextBox by using the method $find and then call the client API method focus which is documented below:

http://www.telerik.com/help/aspnet-ajax/input_clientsideradtextbox.html

This being said you should modify your code as shown below:

function rttPromptShow(sender, eventArgs) { 
  
   
  
setTimeout(
  
  
function() {
var txt = $find("<%=txtTest.ClientID %>");
try {
  if (txt)
    txt.focus(); 
  
}


Best wishes,
Svetlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ToolTip
Asked by
Kevin Farmer
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or