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

2 posts, 0 answers
  1. Vitaly
    Vitaly  avatar
    78 posts
    Member since:
    Aug 2011

    Posted 28 Aug 2013 Link to this post

    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.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Aug 2013 Link to this post

    Hi Vitaly,

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

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

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


Back to Top