Try our conversational search powered by Generative AI!

Access data and events on a XForm created in edit mode

Vote:
 

Hi.
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.

Thanks
Magne Ingvaldsen

 

#25469
Oct 27, 2008 17:01
Vote:
 

Hi Magne!

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
Linus Ekström
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.

#25476
Oct 28, 2008 1:55
Vote:
 

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" />
  </XForms:XFormControl>

In the code behind i have added the method for OnBeforeSubmitPostedData, but the event never fires. 

Thanks
Magne Ingvaldsen 

#25499
Oct 28, 2008 12:29
Vote:
 

Hi again!

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.

#25511
Oct 28, 2008 19:16
Vote:
 

Thanks Linus. 
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?

Thanks
Magne Ingvaldsen 

#25526
Oct 29, 2008 8:32
Vote:
 

Never mind, i found a solution.

 

XForm form = XForm.CreateInstance(new Guid((String)CurrentPage["PropertyName"]));

 

#25527
Oct 29, 2008 9:09
Vote:
 

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

#52176
Jul 11, 2011 6:02
Vote:
 

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?

#52177
Jul 11, 2011 6:21
Vote:
 

Hi,

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?

#52179
Jul 11, 2011 6:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.