The project illustrates how to bubble an event from Web User Control to the web page that may display something on Web Page according to which event is fired in this User control. To achieve that, we declare a delagate and an event in the user control code behind, add one button to this User Control. Add the following lines of code in the click event of button of User Control.
if (MyEvent != null)
{
this.MyEvent(sender, e);
}
Response.Write("User Control��s Button Click <BR/>");
In the Default.aspx.cs file,Load the usercontrol, and subscribe the event of the user control in the page load event. Define a suitable event handler to display the dropdownlist selected value.
You can find more code samples that demonstrate the most typical programming scenarios by using Microsoft All-In-One Code Framework Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates. If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.
No comments:
Post a Comment