V8 Form Migration
7 min
activate web forms are composed with a series of web controls all previous activate web controls were based on asp net webforms technology and have been completely rewritten in net core this technology rendered standard html + javascript to web browser and then posts back an html form to the server which then emulates events and binds the data into the job that is kept in session memory on the server the new controls render an xml document and a set of bindings to the client where the activate react client displays these controls for the user the controls update the data model and the client which is then submitted to a web service server events are not supported in this environment while every effort has been used to try and maintain compatibility this is sometimes not possible especially with a complete change of underlying architecture the following outlines the process for converting the forms deprecated controls the following controls are no longer supported v7 controls replacement selectmultipleprovisioningobjects this control is no longer necessary as the underlying controls now support multiple selections workflowtreeview this control is used to select a step from a running job selectworkflowstep this is a control based on the standard selectxxx controls and is more consistant autosearchcontrol and searchresultspanel these controls were used to show suggestions and help during log a call style tasks this has been standardized on a more standard search control \<search activatebind=" " /> customvalidator this is a server based control that allow custom validation to be performed on the server this control can be replaced with an expressionvalidator or setting a page error for example v7 version activateusagedatasource this control has been renamed to better represent what it does activatedatasource rename the control to activatedatasource the datasourceid has been retired the activatedatasource now adds a global variable to the evaluator with the name that is the same as it's id property this means the datasource can now be "=//\[id]" in the web grids datasource \<activatewebgrid id="serv1" datasource="=//toptasks" height="300px" selecttype="none" title="top requests"> fileupload binding has changed to binding/item style assetuniquevalidator no longer exists customvalidator or expressionvalidator use a webform form submit/setcontrolerror server script to run your validation logic https //activate activatelive com/articles/2bef775b 1458 4610 8c10 a79a20c93bc1 \<selectmultipleprovisioningobjects id="selectmultipleprovisioningobjects1" activatebind="users" label="users"> \<controls> \<selectuser id="selectuser1" activatebind="" /> \</controls> \</selectmultipleprovisioningobjects> \<selectuser id="selectuser1" activatebind="users/user" multiple="1" /> \<customvalidator id="customvalidator1" /> public void form submit(object sender, eventargs a) { innovation activate web controls customvalidator val = (innovation activate web controls customvalidator)getcontrol("customvalidator1"); if(error) val errormessage = "please select at least one user to request information from " } v8 version public void form submit(activatehttprequest request) { if(error) { request page setpageerror( "please select at least one user to request information from "); } } \<activatewebgrid id="serv1" datasourceid="toptasks" height="300px" selecttype="none" title="top requests"> \</activatedatasource> \<activatedatasource id="toptasks" type="currenttoptasks" maxrows="10"> \<fileupload id="fileup" label="file to import" maxinputs="1" isrequired="true" activatebind=" fileup/item "> fileupload server events the previous asp net //asp net web form event handlers are no longer supported these event handlers were designed to make it easy for users coming from a desktop background to move to the web however, more modern techniques are now available these events are now handled during the form submit event the following is a form from v7 that has a click event that sends an email the highlighted sections are the event handlers that need to be changed \<?xml version="1 0" encoding="utf 16"?> \<webform> \<panel width="100%" form load="form load" form submit="form submit"> \<controls> \<ribbonpanel> \<controls> \<ribbongroup text="email"> \<controls> \<ribbonbutton link="/" click="onsend" text="send" imageurl="mail"> \</ribbonbutton> \</controls> \</ribbongroup> \</controls> \</ribbonpanel> \<break id="break1" /> \<textbox id="txtemail" label="email address" width="800px" text="=/user/emailaddress" /> \<textbox id="txtsubject" label="subject" width="800px" text="=eval(=//job, \"\")" /> \<htmleditor id="txtbody" label="message" width="800px" html="=eval(=//job, \"\")" /> \</controls> \</panel> \<serverscript> \<text>\<!\[cdata\[using system; using system web ui; using innovation activate; using innovation activate utilities; using innovation activate web; using innovation activate forms xaml; using innovation activate web controls; class script webformscript { public void form load(object sender, eventargs e) { } public void form submit(object sender, eventargs a) { } public void onsend(object sender, menulinkclienteventargs a) { textbox txtemail = (textbox)getcontrol("txtemail"); textbox txtsubject= (textbox)getcontrol("txtsubject"); htmleditor txtbody = (htmleditor)getcontrol("txtbody"); mailutilities sendemail(txtemail text, txtsubject text, txtbody html); webutils gotoreturnpage(); } } ]]>\</text> \</serverscript> \</webform> the new version based on v8 \<?xml version="1 0" encoding="utf 16"?> \<webform> \<panel width="100%" form load="form load" form submit="form submit"> \<ribbonpanel> \<ribbongroup text="email"> \<ribbonbutton id="btnsend" text="send" imageurl="mail"> \</ribbonbutton> \</ribbongroup> \</ribbonpanel> \<break id="break1" /> \<textbox id="txtemail" label="email address" width="800px" text="=/user/emailaddress" activatebind="email/emailaddress" /> \<textbox id="txtsubject" label="subject" width="800px" text="=eval(=//job, \"\")" activatebind="email/subject" /> \<htmleditor id="txtbody" label="message" width="800px" html="=eval(=//job, \"\")" activatebind="email/body" /> \</panel> \<serverscript> \<text>\<!\[cdata\[using system; using innovation activate; using innovation activate utilities; using innovation activate web; using innovation activate forms xaml; using activate web controls; using innovation activate web controls; class script webformscript { public void form load(object sender, eventargs e) { } public void form submit(activatehttprequest request) { if (request iseventsource("btnsend")) { string email = job arguments getstring("email/emailaddress"); string subject = job arguments getstring("email/subject"); string body = job arguments getstring("email/body"); mailutilities sendemail(email,subject, body); page returntopreviouspage("email sent"); } } } ]]>\</text> \</serverscript> \</webform> explanation ribbonbutton removed click="" handler this property could be left but would not do anything added an 'id' this id is used to identify what button was clicked on the server form submit now returns a value this value tells the system what the result of the action is for example, valid return results could be set a page error and return return page defaultaction(); return page nextpage(); can have an activatehttprequest object as a parameter the activatehttprequest object allows access to information about the request the previous form submit arguments are still valid and will still work the request object can be obtained from page request form submit(object sender, eventargs a) { page request } control bindings the 'controls' are no longer available during a form submit instead, all values must be bound into the job the script can then read these values from the job the form submit could update the job with information and then regenerate the form by returning page defaultaction();