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
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.
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
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
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.
Thanks a lot.it is working .....:)
Regards,
Bharath