ASP. NET development: add events to user controls

Source: Internet
Author: User

In ASP. NET Development: Adding properties to user controls this article defines a user logon user control UserLogin. the ascx file contains a LinkButton server button control. When you click this button, the server automatically generates a response to stimulate the Page. load event. In addition to the automatic sending of pages generated by the server. in addition to the Load event, we can add an event of our own to the LinkButton. It is actually very easy to add the event. By declaring the event in the <script> </script> block, add the event to the user control. The following example shows how to add events to the UserLogin. ascx user control.

UserLogin. ascx Public event Eventhandler Login; // Add event handle

Void MyOnClick (Object Sender, EventArgs e ){

If (Login! = Null)

Login (this, new EventArgs (); // activate the Login event

} </Script>

Use custom events on the ASPX page:
<%@Register TagPrefix=”wen” TagName=”UserEvent” src=” UserLogin.ascx”%>

Note: The OnLogin event here is an event we add to the UserLogin. ascx file of the user control.

Related Articles: ASP. NET development: Adding properties to user controls (

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.