Can I set the value in a Xform field on pageLoad or on submit?
I need to add a page value to a hidden field in a Xform and then pass it along with the posted data.
/martin
It's possible to set a value for a field when loading a form or when saving form data. You do not even have to have a hidden field for this if you do not want to as it is possible to store additional form data for xforms. Here is an example of how to set form data:
private void Page_Init(object sender, System.EventArgs e)
{
FormControl.BeforeSubmitPostedData +=new SaveFormDataEventHandler(FormControl_BeforeSubmitPostedData);
}
private void FormControl_BeforeSubmitPostedData(object sender, SaveFormDataEventArgs e)
{
e.FormData.SetValue("MyCustomField", "SomeValue");
}
For more info and examples, please see the alternative xforms user control:
http://www.episerver.com/en/EPiServer_Knowledge_Center/developerforum/2628/6042/6043/
See also the new tech note, "Developing with XForms", that was released with the 4.60-documentation:
http://www.episerver.com/en/EPiServer_Knowledge_Center/Library/Technical_Notes/
I'm trying to do this in 4.61.5.83, but get the following exception message: "Expression must evaluate to a node-set.".
Has it changed since last year?
Regards,
/Patrik