Can I debug Xforms save button

Vote:
 

We've got a problem with our xforms. Nothing is saved to the database and the page you are supposed to forwarded to after replying to the questions doesn't show. Is there a way to debug the save button in the xforms so that I can find out what's wrong?

#49990
Apr 08, 2011 6:42
Vote:
 

I don't know about debugging the button itself, but you can attach to a number of events like BeforeSubmitPostedData and see if they get hit at all.

A mistake i saw once was that in the BeforeSubmitPostedData there was a condition that could mean that sometimes a Response.Redirect was performed. That ends the request, so the for the client I was helping with this problem it appeared as the posted data was lost at random (when the condition was fulfilled and the redirect performed).

If the ChannelOptions don't include database you won't get it saved either. So if it is not set on the form it won't save to database. Or if you change the options in an event handler it won't get saved.

#49991
Apr 08, 2011 7:26
Vote:
 

We've never had any event in BeforeSubmitPostedData so tried adding an event to by FormControl.BeforeSubmitPostedData += new SaveFormDataEventHandler(FormControl_BeforeSubmitPostedData); and put string test = ""; inside of it and marked it with a breakpoint. Nothing happened. That's bad, right? ;)

These ChannelOptions you mention, what are they? I can't seem to find them.

I also tried the e-mail response instead of saving to database and nothing happened.

#49993
Apr 08, 2011 7:52
Vote:
 

When you define the XForm in edit mode you set whether it should send email, save do DB or both. In the events (like BeforeSubmitPostedData) the eventargs contain the ChannelOption somwhere. That is often used if you send custom emails so you can remove the email option from channel optionns to avoid duplicate mails.

If not even the before event is hit I don't know what might be wrong. Do you have any global XForms events defined in Global.asax or an InitalizableModule for example?

#49994
Apr 08, 2011 8:02
Vote:
 

There are some events in Global.asax but they have been there the whole time. They came with the public templates which the site is built from. For example there is this:

public void XForm_BeforeSubmitPostedData(object sender, SaveFormDataEventArgs e)
{
    XFormControl control = (XFormControl)sender;

    PageBase currentPage = control.Page as PageBase;

    if (currentPage == null)
    {
        return;
    }

    //We set the current page that the form has been posted from
    //This might differ from the actual page that the form property exists on.
    e.FormData.PageGuid = currentPage.CurrentPage.PageGuid;
}

I'm afraid it's the same thing, even with a break point inside of it nothing happens when the xform is saved. I'm starting to think that this has something to do with our messed up handlers in web.config. Some parts of the edit mode has stopped functioning after we implemented Ajax. Search, My settings, Report center, etc. We've got some Xforms still working though so I don't think they're connected.

#49995
Apr 08, 2011 8:18
Vote:
 

I found what was wrong. We had two xforms on the same page, one in the right side column with a simple poll. Turns out that's a big no-no!

Problem solved!

#50084
Apr 12, 2011 13:57
Vote:
 

Ah... If you need multiple xforms, try varying the ValidationGroup as suggested here: http://world.episerver.com/Modules/Forum/Pages/thread.aspx?id=47274

#50085
Apr 12, 2011 13:59
Vote:
 

I'll keep that in mind. Thanks for the tip!

#50086
Apr 12, 2011 14:01
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.