1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

dynamic control event

Discussion in 'C#' started by pw_jamison, Aug 28, 2010.

  1. pw_jamison

    pw_jamison New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    i know this partially asp.net as well...

    if i create an custom control like this

    protected void Page_Load(object sender, EventArgs e)
    Control myUserControl = (Control)LoadControl("MyControl.ascx");

    is there a way of responding to an event within that control...

    private void Button1_Click(object sender, System.EventArgs e)
    Response.Write("WebUserControl1 :: I am in the control");

    without specifically creating an instance of the control...

    MyControl realControl = new MyControl();
    realControl.myEvent += new EventHandler(FormEvent);

    Where FormEvent is an event on the form triggered by the event on the control.

    hope this makes sense.

Share This Page