Create and use Web Components in ASP. NET

Source: Internet
Author: User

Some time ago, I needed to dynamically create WEB Components during development. I thought it was a trivial matter, but it was easy to do it. There are some minor issues. Next, I will introduce how to dynamically create and use WEB Components Based on my own programs, hoping to provide some help to my friends who do similar jobs.
I. Program ideas
The program consists of three parts:
1. The program determines the number of WEB components to be created based on the data information in XML.
2. dynamically create WEB components.
3. Use dynamically created WEB components.
2 and 3 are the important parts of this article.
Next I will introduce these three parts in combination with program instances (taking c # as an example.
Ii. Read XML files
Reading XML files is detailed in many documents, and I believe many of my friends have mastered the technology. However, to ensure the integrity of the article, I would like to repeat it here. A friend with a deep harmonic flavor can skip this section.
The XML file to be read in my program is shown below:
Config. xml
<? Xml version = "1.0"?>
<Nettype> net </Nettype>
<Totalnum> 6 </Totalnum>
<Cells> 2 </Cells>
<Name> site 1 </Name>
<IP> </IP>
<Sequence> 1 </Sequence>
<Name> Site 2 </Name>
<IP> </IP>
<Sequence> 2 </Sequence>
... ...
The Program for reading XML files is as follows:
Protected void readconfig ()
System. Xml. XmlDocument mXmlDoc = new System. Xml. XmlDocument ();
MXmlDoc. Load (Server. MapPath (configfilepath ));
Nettype = mXmlDoc. selectNodes ("// Root/Nettype") [0]. innerText; totalnum = int. parse (mXmlDoc. selectNodes ("// Root/Totalnum") [0]. innerText );
// Read the number of Columns
Cells = int. Parse (mXmlDoc. SelectNodes ("// Root/Cells") [0]. InnerText );
XmlNodeList mXmlNodes = mXmlDoc. SelectNodes ("// Root/IPlink ");

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: 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.