Custom Control question RRS feed

  • Question

  • User-84796694 posted


    I am creating the following:

    1 user control  (UC) -- contains a label (Label1)
    1 custom control (CC) -- will inherit from button control & contains a pointer to UC
    1 aspx page (this will contain 1 CC and 1 UC)

     it is the job of the CC to alter the user control in the following manner:

    1) CC is clicked
    2) CC's OnClick event changes value of UC's Label1
    3) The aspx page displays the new value of UC's Label1

    The problem is, I do not know how to send UC as a parameter to CC. You can do it with regular controls, but ddon't know how with User Controls. Here is an example of what I want to do:

    //This works for the Label Web Control....
    public class CustomButton : Button
        Label label;

        public CustomButton(Label label)
    this.label = label;

    //But can't understand how to do it for the User Control....
    public class CustomButton : Button
        UC1 uc1;   //Will not recognize the UC1 className

        public CustomButton(UC1 uc1)
    this.uc1 = uc1;

    How do i do this???

    Sunday, March 16, 2008 3:04 AM


  • User2032526919 posted


    is this a web app project in Vs2005/2008 or just standard web site project? And not in separate class library? With web site project User controls are built after class files - this is relevant - if you have these all in the same web site project. If the custom control is in separate project, it's still valid as the project would need to have reference to the type containing the UC. So basically it's about referencing the type containing the UC.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 16, 2008 5:16 AM