Dynamic Loading of user controls and their events using the webpage ammonium button

Source: Internet
Author: User

Development requires that a user control Form and button event need to be moved to the webpage for processing.
What should I do? For example, the user control has a text box, a single selection, and a button. Originally, the processing logic is processed in the user control. Now these logic processes need to be moved to the web page.
What is the web page? The webpage also has a button. When the user clicks this button, the button event dynamically loads the user control.
After the operation user enters the text box, select the single option and click the Save button. The entered information needs to be displayed on the webpage.
This is what it looks like.

Insus. NET first designs User Controls:


Go to. UcA. ascx. cs to write code,


Create a webpage in the site:



When you click the button on the webpage to load the user control, and the user clicks the button again, the status of the webpage disappears, that is, the lifecycle has ended. To solve this problem, refer to this article first:
Http://www.cnblogs.com/insus/archive/2012/10/09/2717420.html


Write a method to dynamically load User Controls




There is a delegate UcA1_Saving ()


After preparation is complete, Insus. NET writes the Click Event of the button of the webpage:



As we mentioned earlier, after the operator clicks the user control to save the button, the webpage status will be retained. Therefore, some programs need to be executed in the Page_Load event of the webpage:



After that, let's see the animation demonstration:



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.