Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending XML Data Using a Web Form

Status
Not open for further replies.

chieftain1

Technical User
May 30, 2006
6
US
How can I send XML data from a Web form? I’m using VS.NET. I have no problem sending data that’s inserted in Web form text boxes and I’m trying to use a similar routine to send the XML. I can view the XML data on the Web page because I’ve inserted an XML Control that references my stylesheet (XSL). Am I suppose to use something called a DataSet instead? Here’s the code I have so far in C# (The section in question is in bold type):

Code:
namespace Forms
{
	public class Table : System.Web.UI.Page
	{
		protected System.Web.UI.HtmlControls.HtmlForm Form1;
		protected System.Web.UI.WebControls.CheckBoxList disseminationList;
		protected System.Web.UI.WebControls.Xml calibrationFileList;
		protected System.Web.UI.WebControls.Button btnSubmit;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		private void InitializeComponent()
		{    
			this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnSubmit_Click(object sender, System.EventArgs e)
		{
			//  load an xml document from the basic soap package file
			XmlDocument msg = ((Global)Context.ApplicationInstance).SoapSetup( "xmlCTU" );
[b]
//  get the base calTableUpdate node for data values
			XmlNode tab = msg.GetElementsByTagName( "FileList" )[0];

//  set user data values in the message content area
			tab[ "Element1" ].InnerText = FileList.ToString();
			tab[ "Element2" ].InnerText = FileList.ToString();
			tab[ "Element3" ].InnerText = FileList.ToString();
			tab[ "Element4" ].InnerText = FileList.ToString();
[/b]

//  submit the document
			string rez = ((Global)Context.ApplicationInstance).SoapSubmit( msg, "adrCTU", "hdrCTU" );

			//  if successful redirect to the refering page
			if ( rez == "Success!" ) Response.Redirect( Request.UrlReferrer.AbsoluteUri );

				//  if error show message
			else Response.Write( string.Format( 
					 "<span style=\"FONT-WEIGHT: bold; COLOR: red\">{0}</span>", rez ) );
		}
	}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top