How to: Add XML Web Server Controls to a Web Forms Page
Add XML Web server controls to the place in the page where you want the output to appear.
To add an XML Web server control to a Web Forms page
Type an <asp:XML> element into the page. For syntax, see XML Web Server Control.
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 Web Server Control.
Note You need to be sure that when your application runs, it has sufficient permissions to read the XML file.
To add a control to a Web Forms page programmatically
Create an instance of the control and set its properties:
Dim myXML As System.Web.UI.WebControls.Xml = _ New System.Web.UI.WebControls.Xml() myXML.DocumentSource = "SourceDoc.xml" myXML.TransformSource = "SourceTrans.xsl"
System.Web.UI.WebControls.Xml myXML = new System.Web.UI.WebControls.Xml(); myXML.DocumentSource = "SourceDoc.xml"; myXML.TransformSource = "SourceTrans.xsl";
Add the new control to the Controls collection of a container already on the page:
PlaceHolder1.Controls.Add(myXML)
PlaceHolder1.Controls.Add(myXML);
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 ASP.NET State Management Overview.