See my reply in "Re: Dynamicly loaded User Control events in a Placeholder"
Search MSDN for EventHandler to get a listing of info & samples.
/*
* #C snippet showing how to create a user control & add an event handler
* CWebUserControl1 has an event called Alerted, the aspx defines a function
called Alerted2.
* Note the use of += when setting the EvnetHandler.
* The WebUserControl's classname "CWebUserControl1" is set in the ascx file
using the ClassName parameter of the @Control directive
* <%@Control language="C#" ClassName="CWebUserControl1"%>
*/
public void Page_Load(Object sender, EventArgs e) {
CWebUserControl1 ctl = new CWebUserControl1();
ctl = (CWebUserControl1) LoadControl ("WebUserControl1.ascx");
ctl.Alerted += new EventHandler(this.onAlerted2);
ph1.Controls.Add (ctl);
return;
}
ccallen
"Chris Kennedy" <> wrote in message
news:%23$...
> Can anyone tell me how to reference a a control, e.g. a control I have
added
> to the controls collection without specifically naming it. Also can anyone
> give me some pointer on how to attach events to them. Regards.
>
>
|