This is a migrated thread and some comments may be shown as answers.
how to get the label control inside a panel
1 Answer 69 Views
This is a migrated thread and some comments may be shown as answers.
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Bharathwajan Venkatanarayanan asked on 07 Oct 2009, 10:13 AM
hi,

i want to get the lable inside a panelbar
i have tried the following but the value is null.

var

 

lblEmail = document.getElementById('pnlbarRegn.FindItemByValue("AccountHolderInformation").FindControl("lblEmail").ClientID >');

 


the client code looks like the follwoing

my panel bar name is pnlbarRegn

<

 

telerik:RadPanelItem Enabled="false" Text="Step 3: Account Holder Information" runat="server"

 

 

Font-Underline="false" FocusedCssClass="">

 

 

<Items>

 

 

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

 

 

<ItemTemplate>

 

 

<table width="100%" border="0" cellspacing="0" cellpadding="2">

 

 

 

<tr>

 

 

<td align="right">

 

Email

 

</td>

 

 

<td align="left">

 

 

<telerik:RadTextBox ID="txtEmail" runat="server" Skin="" CssClass="text" MaxLength="255"

 

 

AutoPostBack="false" onfocus="Text1_focus()">

 

 

</telerik:RadTextBox><asp:RequiredFieldValidator ID="rfvEmail" runat="server" Display="Dynamic"

 

 

ControlToValidate="txtEmail" ErrorMessage="E-mail is required" Text="E-mail Required" ValidationGroup="accountHolderInfo" />

 

 

<asp:RegularExpressionValidator ID="regEmail" runat="server" ControlToValidate="txtEmail" Display="Dynamic" ErrorMessage="Enter Valid Email"

 

 

ValidationGroup="accountHolderInfo" ValidationExpression ="^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"></asp:RegularExpressionValidator>

 

 

<asp:Label ID="lblEmail" runat="server" Visible="false" ForeColor = "Red" ></asp:Label>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

 

</ItemTemplate>

 

 

</telerik:RadPanelItem>

 

could any one help me in this regard?

Thanks,
Bharath

1 Answer, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 07 Oct 2009, 11:44 AM
Hi Bharathwajan Venkatanarayanan,

You cannot access the label control on the client as it is not rendered on the page yet, because you have set its visibility to false:

... 
... 
<asp:Label ID="lblEmail" runat="server" Visible="false" ForeColor="Red"></asp:Label> 
... 
... 

Here's your modified code snippet that shows the needed approach.

<form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
    <telerik:RadPanelBar ID="pnlbarRegn" runat="server"
        <Items> 
            <telerik:RadPanelItem runat="server" Text="Root RadPanelItem1"
                <Items> 
                    <telerik:RadPanelItem Enabled="true" Text="Step 3: Account Holder Information" runat="server" 
                        Font-Underline="false" FocusedCssClass=""
                        <Items> 
                            <telerik:RadPanelItem runat="server" Value="AccountHolderInformation"
                                <ItemTemplate> 
                                    <table width="100%" border="0" cellspacing="0" cellpadding="2"
                                        <tr> 
                                            <td align="right"
                                                Email 
                                            </td> 
                                            <td align="left"
                                                <telerik:RadTextBox ID="txtEmail" runat="server" Skin="" CssClass="text" MaxLength="255" 
                                                    AutoPostBack="false" onfocus="Text1_focus()"
                                                </telerik:RadTextBox><asp:RequiredFieldValidator ID="rfvEmail" runat="server" Display="Dynamic" 
                                                    ControlToValidate="txtEmail" ErrorMessage="E-mail is required" Text="E-mail Required" 
                                                    ValidationGroup="accountHolderInfo" /> 
                                                <asp:RegularExpressionValidator ID="regEmail" runat="server" ControlToValidate="txtEmail" 
                                                    Display="Dynamic" ErrorMessage="Enter Valid Email" ValidationGroup="accountHolderInfo" 
                                                    ValidationExpression="^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"></asp:RegularExpressionValidator> 
                                                <asp:Label ID="lblEmail" runat="server" Text="lbl" Style="display: none" ForeColor="Red"></asp:Label> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </ItemTemplate> 
                            </telerik:RadPanelItem> 
                        </Items> 
                    </telerik:RadPanelItem> 
                </Items> 
            </telerik:RadPanelItem> 
        </Items> 
    </telerik:RadPanelBar> 
    <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1"
 
        <script type="text/javascript"
 
            function Text1_focus() { 
                var lblEmail = $get('<%= ((Label)pnlbarRegn.FindItemByValue("AccountHolderInformation").FindControl("lblEmail")).ClientID %>'); 
                alert(lblEmail); 
            }   
        </script> 
 
    </telerik:RadScriptBlock> 
    </form> 


Regards,
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.
Asked by
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Answers by
Paul
Telerik team
Share this question
or