events of usercontrol
-
Hi everybody, How do I handle the events of my user control (*.ascx) from the containing page (*.aspx.cs )? Thank you
The easy way is to make the items that fire events public, but the good way is to expose the events in the control, and subscribe to them in the containing page. Christian Graus - Microsoft MVP - C++
-
The easy way is to make the items that fire events public, but the good way is to expose the events in the control, and subscribe to them in the containing page. Christian Graus - Microsoft MVP - C++
-
In the control public delegate void ClickEvent(); public ClickEvent OnClick = null; private void click_button(object sender, EventArgs ea) { if (OnClick!=null) OnClick(); } in the page in page load : myControl.OnClick += new myControl.ClickEvent(this.ControlClick); then: private void ControlClick() { } You can add arguments to the delegate if you'd like, or just expose an EventHandler ( from memory ), which means it has the same args as the event in the first place. Christian Graus - Microsoft MVP - C++