Re: [Xsltforms-support] XSLTForms with ASP.NET
Brought to you by:
alain-couthures
From: Dan M. <dan...@gm...> - 2011-12-17 04:01:35
|
William, Thank you for sharing this story. It is always good to hear of knowledgeable people showing the rest of the world "The Declarative Way". I hope your team shares their results with others. - Dan On Fri, Dec 16, 2011 at 3:11 PM, William David Velasquez < wi...@bi...> wrote: > Hi XForms fans! > > I just saved tons of work using XForms instead of WebForms in a .NET > project I´m currently working. > > It's pretty easy to include an XForms in a ASP.NET page using XSLTForms > and the asp:Xml Control for a server side transform. This line does the > trick: > > <asp:Xml ID="Xml1" runat="server" DocumentSource="~/myform.xforms" > TransformSource="~/xsltforms/xsltforms.xsl" EnableViewState="False" > ></asp:Xml> > > And to process the submission with DOM, two lines do the work: > > <%@ Page Language="C#" %> > <% > System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); > doc.Load(Request.InputStream); > > // process your xml here.... > > %> > > There is just two things to keep in mind: > > 1. You need the latest version of XSLTForms from the repository (I > tested with rev 521). Previous versions don´t work with .NET > transformation engine. > > 2. ASP.NET WebForms wraps all the controls in the page with <form > >...</form> so when the Xml Control renders the xhtml for the XForm, > clicking in the xf:triggers post the form submission (an undesirable > behavior) because they are rendered as <button> with the default > type=submit. > > There are to workarounds: > 1. Move the <asp:Xml> outside the <form runat="server"> tag in the aspx > page, > 2. When that isn't possible (for example, when you use MasterPages), > make a little modification in xsltforms.xsl to add the atributte > type="button" when triggers are rendered. This is done in this template > (line 1141 in rev 521): > > <xsl:template match="xforms:trigger|xforms:submit" ... > > Below is the generation of the <button> tag (line 1162 in rev 521): > > <button> > <xsl:copy-of select="$innerbody"/> > </button> > > You can add the attribute this way: > > <button> > <xsl:attribute name="type">button</xsl:attribute> > <xsl:copy-of select="$innerbody"/> > </button> > > I know monsieur Alain kindly will include this change in a future > release ;-) > > I'm getting mixed reaactions from my co-workers (most of them are MS > fans), so I asked them to write a form using the normal aspnet way to > calculate an invoice, allowing users to add details lines, sum totals, > taxes, etc. They had to write more than 50 tricky lines of code, with > events handlers, javascript and a lot of Googling. Then I showed it with > XForms: five xf:bind and two xf:trigger for custom logic > > No need to say they are starting to get convinced. > > Merry Christmas, > > > William Velasquez > > > ------------------------------------------------------------------------------ > Learn Windows Azure Live! Tuesday, Dec 13, 2011 > Microsoft is holding a special Learn Windows Azure training event for > developers. It will provide a great way to learn Windows Azure and what it > provides. You can attend the event by watching it streamed LIVE online. > Learn more at http://p.sf.net/sfu/ms-windowsazure > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support > -- Dan McCreary Semantic Solutions Architect office: (952) 931-9198 cell: (612) 986-1552 |