ASP. NET basics of Dynamic Control Loading

Source: Internet
Author: User

 

There are a lot of arguments about whether to use dynamic controls. I personally like to use this method for development,

On the one hand, it is very important for me to set parameters in a program. Otherwise, if the code is too long, you have to get an error, you need to find out which side is set everywhere.

On the other hand, it is conducive to the subsequent program abstraction. My habit is that after the program code is too large, I will start to think about what can be shared and then abstract it for use.

 

The following is a simple example of Hello World.

 

1 <% @ Page Language = "C #" AutoEventWireup = "True" %>

2

3 <script language = "C #" runat = server>

4

5 void SubmitBtn_Click (Object sender, EventArgs e)

6 {

7 Label message = new Label ();

8 message. Text = "Hello World !! ";

9 sourceTag. Controls. Add (message );

10}

11

12 </script>

13

14

15 <meta http-equiv = "content-type" content = "text/html; charset = UTF-8"/>

16

17 <body>

18 <form runat = "server">

19

20

21

22 <asp: Button id = "Button1" Text = "Say Hello" OnClick = "SubmitBtn_Click" runat = "server"/>

23

24 <p>

25 <div id = "sourceTag" runat = "server">

26 </div>

27 <p>

28 Xiaolong

29 </form>

30 </body>

31

 

 

 

The execution screen is as follows:

 

 

 

 

 

In the future, I will take the time to sort out some advanced applications.

 

 

~~~ A dragon (babydragoner )~~~

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.