|
// Copyright (c) 2004 Marc Clifton. All Rights Reserved
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Xml.Xsl;
using MyXaml;
namespace declarativeWeb
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel formPanel;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
SimpleCalc sc=new SimpleCalc();
XmlDocument doc=LoadDocument();
if (doc != null)
{
Parser parser=new Parser();
Panel panel=(Panel)parser.LoadObject(doc, "Calc", sc, null);
if (panel != null)
{
formPanel.Controls.Add(panel);
}
}
Session["SimpleCalc"]=sc;
}
else
{
SimpleCalc sc=(SimpleCalc)Session["SimpleCalc"];
XmlDocument doc=LoadDocument();
if (doc != null)
{
Parser parser=new Parser();
Panel panel=(Panel)parser.LoadObject(doc, "Calc", sc, null);
if (panel != null)
{
formPanel.Controls.Add(panel);
}
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private XmlDocument LoadDocument()
{
XmlDocument doc=null;
string path=MapPath("");
try
{
doc=new XmlDataDocument();
doc.PreserveWhitespace=true;
doc.Load(path+"\\calcForm.xml");
XslTransform xt=new XslTransform();
xt.Load(path+"\\form2web.xslt");
StringBuilder sb=new StringBuilder();
StringWriter sw=new StringWriter(sb);
xt.Transform(doc, null, new XmlTextWriter(sw), new XmlUrlResolver());
doc=new XmlDocument();
doc.LoadXml(sb.ToString());
System.Diagnostics.Trace.WriteLine(sb.ToString());
}
catch(Exception ex)
{
Trace.Warn(ex.Message);
}
return doc;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
My main goal as a developer is to improve the way software is designed, and how it interacts with the user. I like designing software best, but I also like coding and documentation. I especially like to work with user interfaces and graphics.
I have extensive knowledge of the .NET Framework, and like to delve into its internals. I specialize in working with VG.net and MyXaml. I also like to work with ASP.NET, AJAX, and DHTML.