asp.net.ph

Skip Navigation Links

Adding Xml Controls to a Web Forms Page

Controls You Can Use on Web Forms   ASP.NET Standard Controls   Xml Control


Essentially, to create a working Xml control, you need to add the control to the page and bind the control to a data source.

To add an Xml Web server control to a Web Forms page

  1. Declare an <asp:Xml> element into the page. For syntax, see Xml Control Syntax.
  2. Load the XML data that you want to display into the control by setting the Document or DocumentSource property, or by putting the XML between the control’s opening and closing tags. For details, see Loading XML Data in the Xml Control.

To add a control to a Web Forms page programmatically

  1. Create an instance of the control and set its properties:

Xml myXML = new Xml ( );
myXML.DocumentSource = "SourceDoc.xml";
myXML.TransformSource = "SourceTrans.xsl";
  C# VB
  1. Add the new control to the Controls collection of a container already on the page:

PlaceHolder1.Controls.Add ( myXML );
  C# VB

NOTE: Controls that you add dynamically to a Web Forms page do not automatically become part of the page’s view state — neither the controls nor their values are saved when a page performs a round trip to the server. You are therefore responsible for saving the state of any dynamically-generated controls whose values you want to preserve. For details, see Introduction to Web Forms State Management.

See Also

Introduction to the Xml Control   Loading XML Data in the Xml Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note