how to dynamically find label in AJAX Tabcontainter1.

Last post 01-19-2009 4:37 PM by hn_ng@hotmail.com. 1 replies.

Sort Posts:

  • how to dynamically find label in AJAX Tabcontainter1.

    01-19-2009, 2:35 PM

    Hi,

    I have a AJAX tabcontainter with three tabpanels in my web page.  Tabpanel1 has three labels (Label1/Label2/Label3).  I would like reuse the following codes to dynamically find labels and make them invisible during first web site visit.

    The below codes return "null" during debug step.  I added a Label4 outside of the AJAX Tabcontainer and my codes found and made it invisible.

    Please give me some tips.  Regards. Hn

    P.S. I actually comment out the  // Label lbl = (Label)FindControl(labeltmp);

    and tried the Label lbl = (Label)TabContainer1.FindControl(labeltmp);

    Still doesn't work.

    //disable label and image first

    for (int i = 1; i <= 10 ; i++) {

      string labeltmp = "Label" + i.ToString();

      string imagetmp = "Image" + i.ToString();

      // Label lbl = (Label)FindControl(labeltmp);

    Label lbl = (Label)TabContainer1.FindControl(labeltmp);

      if (lbl != null ) {   lbl.Visible = false;

      }

    }

  • Re: how to dynamically find label in AJAX Tabcontainter1.

    01-19-2009, 4:37 PM
    Answer

    I poked around asp.net and found the answer

    for (int i = 1; i <= 10 ; i++) {

      string labeltmp = "Label" + i.ToString();

      string imagetmp = "Image" + i.ToString();

        Label lbl = (Label)TabContainer1.FindControl("tabpanel1").FindControl(labeltmp);

      if (lbl != null ) {   lbl.Visible = false;

      }

    }

Page 1 of 1 (2 items)