November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
On your page template with the xform control, are you setting the forms definition in the onload or oninit event? I had the exact same problem this week when setting via onload - If its the same issue I had, moving the code to oninit should solve the problem.
Adam
By the definition, do you mean the XForm.CreateInstance(new Guid(formGuid));? That occurs within OnInit of a custom control on the page template.
Yeah. I moved all my code to the Page Template for simplicity and verified that the forms definition is set in the Page_Init method for the template. BeforeSubmitPostedData never gets hit.
Sure. Here's the code in the code behind for the template:
protected XForm form { get; set; }
protected void Page_Init(object sender, EventArgs e)
{
var formGuid = CurrentPage["XForm"] as string;
if (!String.IsNullOrEmpty(formGuid))
{
form = XForm.CreateInstance(new Guid(formGuid));
form.PageGuid = CurrentPage.PageGuid;
FormControl.FormDefinition = form;
}
}
That looks ok to me :/ As a try, here is how Im adding a xform to a page in my web app -
protected void Page_Init(object sender, EventArgs e)
{
var propertyValue = CurrentPage.Property["XForm"] as PropertyXForm;
if (propertyValue != null && !propertyValue.IsNull)
{
FormControl.FormDefinition = propertyValue.Form;
}
base.OnInit(e);
}
We've had XForms running on our site, but several months ago we made a series of changes to our website project and one of them seems to have broken these forms. In our implementation, we have a dedicated page template and page type for our XForms pages. In the global.asax, we have the following code in the OnApplicationStart method:
var xformEvents = new XFormEvents();
XFormControl.ControlSetup += new EventHandler(xformEvents.XForm_ControlSetup);
Here's the XFormEvent's XForm_ControlSetup:
public void XForm_ControlSetup(object sender, EventArgs e)
{
var control = (XFormControl)sender;
control.EnableClientScript = true;
control.BeforeLoadingForm += XForm_BeforeLoadingForm;
control.ControlsCreated += XForm_ControlsCreated;
control.BeforeSubmitPostedData += XForm_BeforeSubmitPostedData;
control.AfterSubmitPostedData += XForm_AfterSubmitPostedData;
}
Every time the page is accessed, XForm_BeforeLoadingForm and ControlsCreated get hit as should be expected. However, when you submit the form, you would then expect the BeforeSubmitPostedData and AfterSubmitPostedData to get hit. I've found a few articles that mention issues with AfterSubmitPostedData never getting executed, but not both of these methods. Instead, the form seems to be created anew when its submitted and ControlSetup, BeforeLoadingForm, and finally ControlsCreated are executed. In fact, ControlSetup is executed twice. This is the case whether the submit button is set to both send an email and save to the DB or just save to the DB. It's as if every postback is recognized as a new request to the form.