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

Label inside radpanel . I have label in my aspx page inside RadPanelItem

1 Answer 61 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vitaly
Top achievements
Rank 1
Iron
Iron
Vitaly asked on 28 Aug 2013, 08:57 PM
  1. . I have label in my aspx page inside RadPanelItem:

    <label id="lblPrtHrs" runat="server" for="lblTotalDays" style="margin-left:15px; color:#466D96; font-family:Verdana;">Partial Work Hrs:</label>

     

    In the code behind I try to refer to that label like this:

    ((Label)infoPanel.FindItemByValue("personalInfo").FindControl("lblPrtHrs")).Visible = false;

     

    But getting runtime error:

    Error: Sys.WebForms.PageRequestManagerServerErrorException: Unable to cast object of type 'System.Web.UI.HtmlControls.HtmlGenericControl' to type 'System.Web.UI.WebControls.Label'.

     

    Thanks so much for your help.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Aug 2013, 02:55 AM
Hi Vitaly,

Please check the following code snippet I tried to hide the Label inside the RadPanelItem in OnLoad event.

ASPX:
<telerik:RadPanelBar ID="infoPanel" runat="server" OnLoad="infoPanel_Load">
    <Items>
        <telerik:RadPanelItem runat="server" Text="personalInfo">
            <ItemTemplate>
                <label id="lblPrtHrs" runat="server" for="lblTotalDays" style="margin-left: 15px;
                    color: #466D96; font-family: Verdana;">
                    Partial Work Hrs:
                </label>
            </ItemTemplate>
        </telerik:RadPanelItem>
    </Items>
</telerik:RadPanelBar>

C#:
protected void infoPanel_Load(object sender, EventArgs e)
{
    infoPanel.FindItemByText("personalInfo").FindControl("lblPrtHrs").Visible = false;
}

Thanks,
Shinu.

Tags
General Discussions
Asked by
Vitaly
Top achievements
Rank 1
Iron
Iron
Answers by
Shinu
Top achievements
Rank 2
Share this question
or