I have set the OnClientFocus event of the combobox. When you click on the combobox or tab to it, the function gets called correctly.
If I call combobox.focus() from the server side, or if I get a reference to the Input Dom element client side and focus it, the OnClientFocus function is not fired.
To clarify, when I say client side, I mean when I add the client functions call to the AjaxManager's ResponseScript Collection. When I do this, $find('comboxClientID') returns null. I have tried adding the response script on PageLoad and PreRender.
Here is an example. In the code below, pressing the "Test" button on the page focuses the combobox correctly and the onclientfocus method gets called. If either of the server side methods are called, it does not work. I need to find a solution that will work when initiated on page load or prerender.
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <asp:scriptmanager id="scriptmanager1" runat="server" /> |
| <telerik:radscriptblock id="radscriptblock1" runat="server"> |
| <script type="text/javascript"> |
| function rcb1_ClientFocus(sender, args) { |
| alert('testing'); |
| } |
| function focusComboBox() { |
| var rcb = $find('rcb1'); |
| rcb.get_inputDomElement().focus(); |
| } |
| </script> |
| </telerik:radscriptblock> |
| <telerik:radcombobox id="rcb1" runat="server" onclientfocus="rcb1_ClientFocus" /> |
| <p><input type="button" value="Test" onclick="focusComboBox();" /></p> |
| <telerik:radajaxmanager id="ram1" runat="server"></telerik:radajaxmanager> |
| </form> |
| </body> |
| </html> |
| using System; |
| using System.Collections.Generic; |
| using System.Web; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using Telerik.Web.UI; |
| public partial class Test : System.Web.UI.Page { |
| protected void Page_Load(object sender, EventArgs e) { |
| if (!IsPostBack) { |
| //scriptmanager1.SetFocus(rcb1.ClientID + "_Input"); |
| //RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("focusComboBox();"); |
| } |
| } |
| protected void Page_Prerender(object sender, EventArgs e) { |
| if (!IsPostBack) { |
| //scriptmanager1.SetFocus(rcb1.ClientID + "_Input"); |
| //RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("focusComboBox();"); |
| } |
| } |
| } |