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

Set focus on the radcombobox

2 Answers 705 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vitaly
Top achievements
Rank 1
Vitaly asked on 23 Aug 2011, 04:10 PM
Hi guys,
I have following code in my aspx page:

<

 

tr>

 

 

<td >

 

 

<p class="style" >

 

Please enter job posting number:

 

</p>

 

 

</td>

 

 

<td >

 

 

<telerik:RadNumericTextBox ID="JobPostingNo" runat="server" TabIndex="9" Font-Bold="true" MaxLength="4" Type="Number" MinValue="1" MaxValue="9999" CssClass="textbox" Width="48px" Enabled="false">

 

 

<NumberFormat GroupSeparator="" DecimalDigits="0" />

 

 

<DisabledStyle Font-Bold="true" BackColor="#EFEFEF" />

 

 

</telerik:RadNumericTextBox>

 

 

</td>

 

 

<td>

 

 

<asp:Image ID="JobPNErrImage" runat="server" Width="14px" Height="14px" ImageUrl="~/Image/error-icon.jpg" Visible="false" />

 

 

</td>

 

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<p class="style">

 

Have you met all of the criteria outlined in the posting?

 

</p>

 

 

</td>

 

 

<td>

 

 

<telerik:RadComboBox ID="ddlPost" runat="server" TabIndex="10" AutoPostBack="false" Font-Size="Small" Width="53px">

 

 

<Items>

 

 

<telerik:RadComboBoxItem Text="Select" Value="" Selected="true" />

 

 

<telerik:RadComboBoxItem Text="Yes" Value="Y" />

 

 

<telerik:RadComboBoxItem Text="No" Value="N" />

 

 

</Items>

 

 

</telerik:RadComboBox>

 

 

</td>

 


And here is a code behind file:

RadPanelBar

 

attestPanel = (RadPanelBar)formPanel.FindItemByValue("principalForm").FindControl("attestationPanel");

 

 

RadNumericTextBox jobPostNo = (RadNumericTextBox)attestPanel.FindItemByValue("principalattestaionInfo").FindControl("JobPostingNo");

 

 

RadComboBox ddlAprvPost = (RadComboBox)attestPanel.FindItemByValue("principalattestaionInfo").FindControl("ddlAprv");

 

 

if (ddlAprvPost.SelectedValue == "Y")

 

{

jobPostNo.Enabled =

true;

 

jobPostNo.Focus();

}

 

else

 

{

 

if (jobPostNo.Text.Length > 0)

 

{

jobPostNo.Text =

string.Empty;

 

}

jobPostNo.Enabled =

false;

 

 

}

My question is: when jobPostNo control is disabled how  to shift focus to the next control right after this control.

Thanks so much.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Aug 2011, 06:51 AM
Hello Vitaly,

There are many methods to achieve the same. One approach is to call a client side function from serverside and set focus to the input element
Javascript:
function SetFocus()
{
    var comboBox = $find("<%=RadComboBox1.ClientID %>");
    var input = comboBox.get_inputDomElement();
    input.focus();
}
You can check the following help article which explains how to call javascript functions from server side.
Calling radalert from codebehind (all versions of RadWindow)

The same thing you can achieve from server side as well by using the setFocus method of the script manager.
Javascript:
ScriptManager1.SetFocus(RadComboBox1.ClientID + "_Input");

Thanks,
Shinu.
0
Vitaly
Top achievements
Rank 1
answered on 25 Aug 2011, 09:44 PM
Thanks so much Shinu,
it is working fine.
Tags
General Discussions
Asked by
Vitaly
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Vitaly
Top achievements
Rank 1
Share this question
or