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

Access, Modify and update values for a nested controls

1 Answer 94 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 02 Oct 2008, 04:02 AM
Hello
'm doing some testing with panelbar and I find this problem.

I have a panelbar "deputy code", like this example 
http://demos.telerik.com/aspnet/prometheus/Panelbar/Examples/ApplicationScenarios/AccessingNestedControls/DefaultVB.aspx
where the first page I have to validate a code into a textbox, and verify that the information typed in there is true, otherwise we can show an error report on a label.
as I do, to the extent possible without a postback but using ajax on the same page.

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
            <telerik:RadPanelBar runat="server" ID="RadPanelBar1" Skin="Outlook"
                ExpandMode="SingleExpandedItem" Width="500px">
                <Items>
                    <telerik:RadPanelItem Expanded="True" Text="Paso 1: Codigo de Seguridaed" runat="server" Selected="true">
                        <Items>
                            <telerik:RadPanelItem Value="Codigo_Seguridad" runat="server">
                                <ItemTemplate>
                                    <div style="background-color: #D8E8FF">
                                        <ul class="formList" id="accountInfo">
                                            <li>
                                                <asp:Label runat="server" AssociatedControlID="txt_codseguridad" CssClass = "labels" ID="nameLabel" >Codigo de Seguridad:</asp:Label>
                                                <asp:TextBox ID="txt_codseguridad" CssClass="textInput" runat="server" ValidationGroup="Codigoseguridad" Width="200px" AutoCompleteType="None">
                                                </asp:TextBox>
                                                <asp:RequiredFieldValidator runat="server" ID="accountValidator" ValidationGroup="Codigoseguridad"
                                                ControlToValidate="txt_codseguridad" ErrorMessage="Codigo de Seguridad Requerido" Text="*"></asp:RequiredFieldValidator>
                                            </li>
                                            <li>
                                                <br />
                                                <asp:Label runat="server" Visible="false" CssClass = "labels_error" ID="lbl_Error" Text="" >
                                                </asp:Label>
                                            </li>
                                           
                                        </ul>
                                        <asp:Button runat="server" ID="nextButton" OnClick="validarcodigo_Click" Text="Siguiente" CssClass="nextButton" ValidationGroup="Codigoseguridad" />
                                        <br />
                                    </div>   
                                </ItemTemplate>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelItem>
                                       </ItemTemplate>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelItem>
                </Items>
                <CollapseAnimation Duration="100" Type="None" />
                <ExpandAnimation Duration="100" Type="None" />
            </telerik:RadPanelBar>

I access the controls like this in the same example, but not as assigning the control "lbl_error" some value and you can update and display executed after the procedure.

thanks

Alex

     

1 Answer, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 06 Oct 2008, 12:30 PM
Hi Alex,

We are not quite sure if we clearly understand your question. Still, please find below a sample code snippet that shows how to access templated controls.

ASPX:
<form id="form1" runat="server">  
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">  
            <telerik:RadPanelBar runat="server" ID="RadPanelBar1" Skin="Outlook" ExpandMode="SingleExpandedItem" Width="500px">  
                <Items> 
                    <telerik:RadPanelItem Expanded="True" Text="Paso 1: Codigo de Seguridaed" runat="server" Selected="true">  
                        <Items> 
                            <telerik:RadPanelItem Value="Codigo_Seguridad" runat="server">  
                                <ItemTemplate> 
                                    <div style="background-color: #D8E8FF">  
                                        <ul class="formList" id="accountInfo">  
                                            <li> 
                                                <asp:Label runat="server" AssociatedControlID="txt_codseguridad" CssClass="labels" ID="nameLabel">Codigo de Seguridad:</asp:Label> 
                                                <asp:TextBox ID="txt_codseguridad" CssClass="textInput" runat="server" ValidationGroup="Codigoseguridad" Width="200px" AutoCompleteType="None">  
                                                </asp:TextBox> 
                                                <asp:RequiredFieldValidator runat="server" ID="accountValidator" ValidationGroup="Codigoseguridad" ControlToValidate="txt_codseguridad" ErrorMessage="Codigo de Seguridad Requerido" Text="*"></asp:RequiredFieldValidator> 
                                            </li> 
                                            <li> 
                                                <br /> 
                                                <asp:Label runat="server" Visible="false" CssClass="labels_error" ID="lbl_Error" Text="">  
                                                </asp:Label> 
                                            </li> 
                                        </ul> 
                                        <asp:Button runat="server" ID="nextButton" OnClick="validarcodigo_Click" Text="Siguiente" CssClass="nextButton" ValidationGroup="Codigoseguridad" /> 
                                        <br /> 
                                    </div> 
                                </ItemTemplate> 
                            </telerik:RadPanelItem> 
                        </Items> 
                    </telerik:RadPanelItem> 
                </Items> 
            </telerik:RadPanelBar> 
        </telerik:RadAjaxPanel> 
    </div> 
</form> 

Code-behind:
using System;  
using System.Data;  
using System.Configuration;  
using System.Collections;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
using Telerik.Web.UI;  
 
public partial class _Default : System.Web.UI.Page  
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
 
    }  
    protected void validarcodigo_Click(object sender, EventArgs e)  
    {  
        RadPanelItem myTemplateItem = (RadPanelItem)RadPanelBar1.FindItemByValue("Codigo_Seguridad");  
        Label errorLabel = (Label)myTemplateItem.FindControl("lbl_Error");  
        errorLabel.Visible = true;  
        TextBox myTxtBox = (TextBox)myTemplateItem.FindControl("txt_codseguridad");  
        errorLabel.Text = myTxtBox.Text;  
    }  
}  
 


All the best,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
PanelBar
Asked by
Alex
Top achievements
Rank 1
Answers by
Paul
Telerik team
Share this question
or