Recently I had to add a third party widget (a Travel Planner from TFL) to a Sitecore page (ASP.NET). The widget was a piece of HTML containing a couple of input controls and a form tag that generated an HTTP POST to open a page on another website. So far, so easy. In a normal world (PHP for example) it _should_ be possible to just drop the HTML onto the page and Bob’s your uncle.
Not with ASP.NET and Sitecore.
Adding this trivial piece of HTML to a Sitecore page presents its own unique difficulties.
1.) Sitecore: Adding the HTML as a Rich Text field is futile as the form tags are stripped out by Sitecore, unless added to the page layout itself.
2.) ASP.NET: the Single Form Interface used in ASP.NET (Webforms), means that only one server-side form tag is supported, and the page already contained a server-side form.
<fieldset id="jpForm" style="margin: 5px 0 0 0 !important; padding: 0 !important;"> <input name="language" type="hidden" value="en" /> <!-- in language = english --> <input name="execInst" type="hidden" /> <input name="sessionID" type="hidden" value="0" /> <!-- to start a new session on JP the sessionID has to be 0 --> <input name="ptOptionsActive" type="hidden" value="-1" /> <!-- all pt options are active --> <input style="width: 155px ! important;" name="name_origin" type="text" value="From" /> // more fields etc </fieldset>
The solution to this was to rename the the dropdown lists and then add their selected contents to (correctly named) input controls created and added to the dynamic form thus:
The resulting HTTP POST therefore contains two extraneous parameters (type_destination_form & type_origin_form), but these are ignored by the target page (unsurprisingly as they are not expected).
POST /user/XSLT_TRIP_REQUEST2 HTTP/1.1
And the page works as expected.