How to define event for a page? [modified]
-
Hi my dears, I`ve written a Web UserControl which has a timer with interval and elapsed event. and I want to raise an event in Timer elapsed method. then I defined a delegate and an event in my Web UserControl . Now I should register this event to my default.aspx page and catch the raised event from my web userControl in a method in my default.aspx page. But I dont know how to register event in aspx page! the code I used is :
//my UserControl named reminder.ascx public delegate void myDelegate(string s); public static myDelegate myEvevnt; protected void Page_Load(object sender, EventArgs e) { System.Timers.Timer myTimer = new System.Timers.Timer(); myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed); myTimer.Interval = 3000; myTimer.Enabled = true; } protected static void myTimer_Elapsed(object source, ElapsedEventArgs e) { myEvevnt("hhh"); } //************************************* // my default.aspx page public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { _Default.Event += new reminder.myDelegate (RecieveEvent);//my question is here.What should I write ??? }
-- modified at 3:17 Wednesday 8th November, 2006 -
Hi my dears, I`ve written a Web UserControl which has a timer with interval and elapsed event. and I want to raise an event in Timer elapsed method. then I defined a delegate and an event in my Web UserControl . Now I should register this event to my default.aspx page and catch the raised event from my web userControl in a method in my default.aspx page. But I dont know how to register event in aspx page! the code I used is :
//my UserControl named reminder.ascx public delegate void myDelegate(string s); public static myDelegate myEvevnt; protected void Page_Load(object sender, EventArgs e) { System.Timers.Timer myTimer = new System.Timers.Timer(); myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed); myTimer.Interval = 3000; myTimer.Enabled = true; } protected static void myTimer_Elapsed(object source, ElapsedEventArgs e) { myEvevnt("hhh"); } //************************************* // my default.aspx page public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { _Default.Event += new reminder.myDelegate (RecieveEvent);//my question is here.What should I write ??? }
-- modified at 3:17 Wednesday 8th November, 2006