locked
How to reference a control inside a user control? RRS feed

  • Question

  • User930584213 posted

    I have created a simple user control and when I press a button I want to load some data into one of its labels.  I can't use find control directly from the ContentPlaceHolder (I'm using a master template).  Apparently the user control is its own container.  How do I reference the user control's type?  If I use Object to cast the user control then I can't call FindControl on the user control.  Here's my example that doesn't work:

    Prefix:ControlName oControl = (Prefix:ControlName) oContentPlaceHolder1.FindControl("UserControlName");

     

    Thursday, November 22, 2007 5:28 PM

Answers

All replies

  • User78900492 posted

    Take a look at this post: http://forums.asp.net/t/1182056.aspx

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 22, 2007 5:57 PM
  • User563148522 posted

    I would go back to your user control and add a read/write property "lblNAME_Text" or something like that which would populate the label.

     

    Thursday, November 22, 2007 7:52 PM