I'm using the RadAJAXManager on a web user control and the FocusControl() method to set focus on an AJAX callback to a RadComboBox. The focus operation is working properly however the cursor is at the END of the displayed text. If I tab to the next control and back, the entire text is highlighted allowing me to begin typing and have the ComboBox find the element I'm looking for (this is the desired effect).
Is there a way to highlight the entire text AND execute the FocusControl() method at the same time?
Thanks,
-Ted
Is there a way to highlight the entire text AND execute the FocusControl() method at the same time?
Thanks,
-Ted
13 Answers, 1 is accepted
0
Hi Ted,
I suggest you attach to the OnResponseEnd event of RadAjaxManager and execute the following code in its event handler:
Find attached a sample web site for more details.
Best regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I suggest you attach to the OnResponseEnd event of RadAjaxManager and execute the following code in its event handler:
<script type="text/javascript"> |
function ResponseEnd(sender, eventArgs) |
{ |
window.setTimeout(function(){ |
var combo = $find("<%=RadComboBox1.ClientID %>"); |
combo.selectText(0, combo.get_text().length); |
},100); |
} |
</script> |
Find attached a sample web site for more details.
Best regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
mary cappello
Top achievements
Rank 1
answered on 04 Sep 2008, 03:06 PM
Good day:
I have a similar issue however i have several Text boxes that are on the same form that have this issue...
How would you deal with that. And really why would you have to resort to using javascript just to have the focus highlight the text?
Mary.
I have a similar issue however i have several Text boxes that are on the same form that have this issue...
How would you deal with that. And really why would you have to resort to using javascript just to have the focus highlight the text?
Mary.
0
Hi mary cappello,
To see more information on the requested functionality, please refer to the following articles.
http://www.telerik.com/help/aspnet-ajax/input_commonfocus.html
http://www.telerik.com/help/aspnet-ajax/input_clientsideradtextbox.html
I hope this information helps.
Kind regards,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
To see more information on the requested functionality, please refer to the following articles.
http://www.telerik.com/help/aspnet-ajax/input_commonfocus.html
http://www.telerik.com/help/aspnet-ajax/input_clientsideradtextbox.html
I hope this information helps.
Kind regards,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mary cappello
Top achievements
Rank 1
answered on 04 Sep 2008, 04:45 PM
Good Day:
Actually I'm using a regular asp:textbox not a radInput.
I'm able to achieve focus however it's not selecting the text in the text box.
In order to make it work using javascript it would be a nightmare because there are about 20 of them on the page that need the functionality.
Is there some other way to do this using the RadAjax .FocusControl(txtAddress.ClientID) (this is an example)
Mary.
Actually I'm using a regular asp:textbox not a radInput.
I'm able to achieve focus however it's not selecting the text in the text box.
In order to make it work using javascript it would be a nightmare because there are about 20 of them on the page that need the functionality.
Is there some other way to do this using the RadAjax .FocusControl(txtAddress.ClientID) (this is an example)
Mary.
0
Hi Mary,
Thank you for the clarification. If you prefer to set the focus for your asp TextBox controls on the server, consider using either
<RadAjaxManagerInstance>.FocusControl(txtAddress.ClientID)
or
<ScriptManagerInstance>.SetFocus(txtAddress.ClientID)
methods where RadAjaxManagerInstance or ScriptManagerInstance are the actual ajax manager or script manager objects on the page.
Kind regards,
Stephen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for the clarification. If you prefer to set the focus for your asp TextBox controls on the server, consider using either
<RadAjaxManagerInstance>.FocusControl(txtAddress.ClientID)
or
<ScriptManagerInstance>.SetFocus(txtAddress.ClientID)
methods where RadAjaxManagerInstance or ScriptManagerInstance are the actual ajax manager or script manager objects on the page.
Kind regards,
Stephen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ted
Top achievements
Rank 1
answered on 05 Sep 2008, 01:44 PM
Hi all,
Thanks for your input on this issue, but it seems like the point is being missed. We can all figure out how to get the cursor to sit on the control we want it to be on. That's not the issue. The issue is actually setting the 'CaretPosition' (thanks for the links, Plamen) where desired as well as highlighting the text (i.e. selectAllText() method). If I tab from the initially focused control to the next control, then shift-tab backwards, the text is highlighted correctly. In my case, it's just the first time focus is set that is not highlighting correctly.
I began working with the links that Plamen included yesterday and have had limited success. In my case I'm working with a RadComboBox control (not the RadInput or RadNumericText controls) and have not been able to find the Property/Method page for THAT control.
Also, are there any examples of how these properties/methods need to be implemented? I feel like I'm close, but just missing some bit of syntax (that's why I've waited so long to post). Intuitively, I think I know how these methods should work, but have yet to see success.
Any help you can give will be greatly appreciated.
Thanks,
-Ted
Thanks for your input on this issue, but it seems like the point is being missed. We can all figure out how to get the cursor to sit on the control we want it to be on. That's not the issue. The issue is actually setting the 'CaretPosition' (thanks for the links, Plamen) where desired as well as highlighting the text (i.e. selectAllText() method). If I tab from the initially focused control to the next control, then shift-tab backwards, the text is highlighted correctly. In my case, it's just the first time focus is set that is not highlighting correctly.
I began working with the links that Plamen included yesterday and have had limited success. In my case I'm working with a RadComboBox control (not the RadInput or RadNumericText controls) and have not been able to find the Property/Method page for THAT control.
Also, are there any examples of how these properties/methods need to be implemented? I feel like I'm close, but just missing some bit of syntax (that's why I've waited so long to post). Intuitively, I think I know how these methods should work, but have yet to see success.
Any help you can give will be greatly appreciated.
Thanks,
-Ted
0
mary cappello
Top achievements
Rank 1
answered on 05 Sep 2008, 01:57 PM
Good Day All:
Yes Ted you are right the point is being missed. We too can tab to the next object and Shift tab back and it will be highlighted, however, when you set focus to a control the text should be highlighted, but with the radajaxpanels it does not work. The odd thing is if you use a regular Microsoft Ajax panel it can work just fine but then the other telerik controls don't work properly.
Simply put there should be some way in code behind to set the focus and highlight the text in a text box that is within a RadAjaxPanel. Since it's supposed to be .NET compliant, it should not have to use a client script to do that, it should intuitively already be highlighted upon the focus. Since it is not, there should be a way to do that in codebehind but I have not found a way. I'm thinking of setting the focus to the next object and using sendkeys to tab back to it. But I really think that we should not have to do that.
Mary.
Yes Ted you are right the point is being missed. We too can tab to the next object and Shift tab back and it will be highlighted, however, when you set focus to a control the text should be highlighted, but with the radajaxpanels it does not work. The odd thing is if you use a regular Microsoft Ajax panel it can work just fine but then the other telerik controls don't work properly.
Simply put there should be some way in code behind to set the focus and highlight the text in a text box that is within a RadAjaxPanel. Since it's supposed to be .NET compliant, it should not have to use a client script to do that, it should intuitively already be highlighted upon the focus. Since it is not, there should be a way to do that in codebehind but I have not found a way. I'm thinking of setting the focus to the next object and using sendkeys to tab back to it. But I really think that we should not have to do that.
Mary.
0
Ted
Top achievements
Rank 1
answered on 05 Sep 2008, 02:06 PM
Mary,
The 'sendkeys' option had crossed my mind as well early on. That was certainly a good way to control my program flow in my desktop apps, but now that I'm working with a web app I don't know how to do that. If that's possible, I'd like to know how to do that also, as a side note.
I, also, would expect there to be some way in the codebehind to set the highlighted text, at least in the RadControls. Some of the features are buried in the documentation, so I won't say it's not there but I'm still looking, too.
-Ted
The 'sendkeys' option had crossed my mind as well early on. That was certainly a good way to control my program flow in my desktop apps, but now that I'm working with a web app I don't know how to do that. If that's possible, I'd like to know how to do that also, as a side note.
I, also, would expect there to be some way in the codebehind to set the highlighted text, at least in the RadControls. Some of the features are buried in the documentation, so I won't say it's not there but I'm still looking, too.
-Ted
0
mary cappello
Top achievements
Rank 1
answered on 05 Sep 2008, 02:30 PM
Hi Ted:
at the top of the c# page place:
at the top of the c# page place:
using
System.Windows.Forms;
Then on a web form to use SendKeys...
SendKeys.SendWait("{TAB}"); // this will tab you to the next field.
SendKeys.SendWait("+{TAB}"); // this is equivalent to Shift Tab which will take you back one field.
Mary.
0
Ted
Top achievements
Rank 1
answered on 05 Sep 2008, 03:40 PM
Cool. Thanks, Mary!!
Now, if we can only figure out how to get our text highlighted. I'm still looking. :)
-Ted
Now, if we can only figure out how to get our text highlighted. I'm still looking. :)
-Ted
0
mary cappello
Top achievements
Rank 1
answered on 05 Sep 2008, 04:02 PM
Hi Ted:
I think it's a telerik issue with the RadAjaxPanel .FocusControl I think they need to fix it to work as a regular .focus would work. where it actually highlights the text.
I have found that I can use an object from a different set of components that also has an ajax panel it that will work however that would involve changing my entire app and the one page alone has 8 tabs and inside the tabs there are 3 to 4 small ajax panels. So it would be a nightmare to do.
Mary.
I think it's a telerik issue with the RadAjaxPanel .FocusControl I think they need to fix it to work as a regular .focus would work. where it actually highlights the text.
I have found that I can use an object from a different set of components that also has an ajax panel it that will work however that would involve changing my entire app and the one page alone has 8 tabs and inside the tabs there are 3 to 4 small ajax panels. So it would be a nightmare to do.
Mary.
0
mary cappello
Top achievements
Rank 1
answered on 05 Sep 2008, 09:37 PM
Good Day:
I thought just to see if this would work with a text box ... i would try the javascript approach on just one of the items that I need to do this with. It does not work.
I've tried it with both a regular asp:Textbox as well as a Rad Input Box.
I've tried it with the RadAjaxPanel.FocusControl on the code behind and without it. It does not work at all.
Is there another way to do this. I really do not like using Send Keys as I'm working in a Web app. And really it should just work... you to a set focus on anything that is not inside of a rad ajax panel and that works... So why would this not work?
Mary.
I thought just to see if this would work with a text box ... i would try the javascript approach on just one of the items that I need to do this with. It does not work.
I've tried it with both a regular asp:Textbox as well as a Rad Input Box.
I've tried it with the RadAjaxPanel.FocusControl on the code behind and without it. It does not work at all.
Is there another way to do this. I really do not like using Send Keys as I'm working in a Web app. And really it should just work... you to a set focus on anything that is not inside of a rad ajax panel and that works... So why would this not work?
Mary.
0
Bernardo
Top achievements
Rank 2
answered on 16 Mar 2009, 07:28 PM
Hi all,
In my case, I resolved that in the codebehind as follow (vb code):
In my case, I resolved that in the codebehind as follow (vb code):
RadAjaxPanel1.ResponseScripts.Add("o=document.getElementById('" & |
TextBox.ClientID & "'); o.focus(); o.select();") |
This works for me.
Bye!