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

Focus is not applied to a button inside a panel bar

5 Answers 85 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Bharathwajan Venkatanarayanan asked on 27 Oct 2009, 09:56 AM
Hi,

we are using a panelbar having 6 panelitems.during pageload,by default,the first panelitem will be expanded and there is a label and button control present inside it.our requirement is ,on load the focus should be on button.
if we press enter the next panelitem should get expanded.

my code:

Button

 

btnNext = (Button)pnlbarRegn.FindItemByValue("Welcome").FindControl("BtnNext");

 

btnNext.TabIndex = 0;

btnNext.Focus();

need help.

Thanks,
Bharathwajan

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Oct 2009, 10:31 AM
Hi Bharathwajan,

Try the following code snippet in order to focus to button placed in panelbar item.

C#:
 
protected void Page_Load(object sender, EventArgs e) 
    if (!IsPostBack) 
    { 
        RadPanelItem item = (RadPanelItem)RadPanelBar2.FindItemByText("Welcome"); 
        Button btnNext = (Button)item.FindControl("Button1"); 
        btnNext.Focus(); 
    } 

-Shinu.
0
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
answered on 27 Oct 2009, 10:48 AM
Hi,

I have tried as you suggested but it is not working.
please see my HTML below.

<

 

telerik:RadPanelItem runat="server" Text="Step 1: Welcome" Font-Underline="false"

 

 

Expanded="true">

 

 

<Items>

 

 

<telerik:RadPanelItem runat="server" Value="Welcome" >

 

 

<ItemTemplate>

 

 

<asp:Label ID="lblWelcome" runat="server" TabIndex="-1"></asp:Label>

 

 

<table style="width: 100%">

 

 

<tr>

 

 

<td colspan="2" align="right">

 

 

<table border="0" cellpadding="0" cellspacing="0" class="tbl_button">

 

 

<tr>

 

 

<td>

 

 

<asp:Button ID="BtnNext" runat="server" OnClick="BtnNext_Click" Text="Next"

 

 

CssClass="btn" />

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</ItemTemplate>

 

 

</telerik:RadPanelItem>

 

 

</Items>

 

 

</telerik:RadPanelItem>

Please let me know whether it is feasible.

Thanks,
Bharathwajan

 

0
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
answered on 28 Oct 2009, 05:45 AM
Hi,

i am using a ajaxpanel above the panelbar.
if i tried the focus with out ajaxpanle it is working fine but there is a full postback in the panelbar.
if we tried with ajaxpanel , we are not able to set the focus on the button.

Please explain how to set the focus on button in panelbar which is inside a ajaxpanel.
please see the code below

<

 

telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">

 

<

 

telerik:RadPanelItem runat="server" Text="Step 1: Welcome" Font-Underline="false"

 

 

 

Expanded="true">

 

 

 

<Items>

 

 

 

<telerik:RadPanelItem runat="server" Value="Welcome" >

 

 

 

<ItemTemplate>

 

 

 

<asp:Label ID="lblWelcome" runat="server" TabIndex="-1"></asp:Label>

 

 

 

<table style="width: 100%">

 

 

 

<tr>

 

 

 

<td colspan="2" align="right">

 

 

 

<table border="0" cellpadding="0" cellspacing="0" class="tbl_button">

 

 

 

<tr>

 

 

 

<td>

 

 

 

<asp:Button ID="BtnNext" runat="server" OnClick="BtnNext_Click" Text="Next"

 

 

 

CssClass="btn" />

 

 

 

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</ItemTemplate>

 

 

 

</telerik:RadPanelItem>

 

 

 

</Items>

 

 

 

</telerik:RadPanelItem>

</

 

telerik:RadAjaxPanel>

 

 

 

 

 

Thanks,
Bharath

0
Paul
Telerik team
answered on 30 Oct 2009, 02:32 PM
Hi Bharathwajan Venkatanarayanan,

You can easily focus the needed control on the client, i.e.

<script type="text/javascript"
       function pageLoad() { 
           var txtBox = $get('<%= ((TextBox)RadPanelBar1.FindItemByValue("templateHolder").FindControl("CtlTextBox")).ClientID %>'); 
           txtBox.focus(); 
       }         
   </script>


All the best,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
answered on 30 Oct 2009, 03:16 PM
Hi paul,

Thanks  a lot.it is working .....:)

Regards,
Bharath
Tags
PanelBar
Asked by
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Paul
Telerik team
Share this question
or