The public templates has samples on how to attach event handlers to form events. In brief, the easiest way is to add a XFormControl control on your page and feed it with the value of your xform property. The XFormControl has events that you can attach to when the form is being posted to the server. Here you can add custom validation, add your own custom data (to the form posting) and/or logic like saving the data to your custom location.
Hope this was helpful
EPiServer Development Team
Ps. As forms might be inserted using dynamic content in R2 you might want to attach your event handlers globally. The new public templates in EPiServer CMS 5 R2 uses this approach. Just view the global.asax.cs file in the public templates for samples. Ds.
Thanks for the answer Linus!
I added a <XFormsControl> to my page template, and placed the xform property inside it. I can't get the events to fire when I load/submit the form from the xform property. I have tried many different events, but cannot get any of them to work. I have added the <XFormControl> like this:
<XForms:XFormControl runat="server" EnableViewState="false" ID="XForm" OnBeforeSubmitPostedData="XForm_BeforeSubmitPostedData" />
<EPiServer:Property ID="Property1" PropertyName="Forms" runat="server" EnableViewState="false" />
In the code behind i have added the method for OnBeforeSubmitPostedData, but the event never fires.
It could be the EPiServer:property that shows the form instead of the XFormsControl. You don't have to have a EPiServer Property control on your page, just feed the XFormControl with the property value that you can extract by the CurrentPage["PropertyName"] syntax.
It was the EPiServer property showing the form, and not the XFormControl. Could you please show me how to feed the XFormControl with the EPiServer property value?
Never mind, i found a solution.
XForm form = XForm.CreateInstance(new Guid((String)CurrentPage["PropertyName"]));
XForm form = XForm.CreateInstance(new Guid((String)CurrentPage["XFormprop"]));
IList<XFormData> xfrmdt= form.GetPostedData();
In code window i wrote like that.....after that any idea? how to extract the content in the controls of XForm
If i build tha code is it giving error stating that--> value cannot be null.........actually XFormprop is the name given to Xform in Admin mode.Any one has an idea?
I have one doubt.whether i can create XForm as Admin mode in EPIServer? or can i create XForm by using <XForms:XFormControl> tags in source window? which one i have to follow?
I have developed a page type for different forms, like a contact form, registration form, etc. The page type takes care of sending emails, storing information and other functionality. I can of course easy access data if I put my own forms on this page type, but I would like to access data from a form that is created in the edit mode. I have added the property XForms forms on my page type, and also added the form as a property in the template. I have then created a very simple contact form in the edit mode, and it displays just fine. My problem is accessing the data and the events in the form. I hope you understand my problem.