Detect when Xform throws a validation error after submit

Vote:
 

I've tried to extend the XForm by adding a custom File upload component, but the problem becomes when I upload the file during my onSubmit event, if the XForm throws an error then the file is already uploaded.

I would like to change this so that I can detect if the Xform throws validation errors, then don't upload the file. But if the form is successful, then upload the file.

I've read this page: http://world.episerver.com/Documentation/Items/Tech-Notes/EPiServer-CMS-5/EPiServer-CMS-5-R2-SP2/Developing-with-XForms/

But I'm not familiar with Page.Validators collection, and I'm not sure what a StaticValidator is or how to use it. I have tried to detect if CancelSubmit is true during BeforeReadingPostedData but that didn't seem to do anything.

Am I missing something? Any help please?

#34788
Nov 16, 2009 13:43
Vote:
 

I've figured out one way to do this. I hope it helps someone else.

I checked the form on Postback to see if the page is valid. Then if it was not valid then I did something.

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // do something for first time loading the page
            }
            if (Page.IsPostBack)
            {
                Page.Validate();
                if (!Page.IsValid)
                {
                    // do something if when submitting the form, the form values are not valid
                }
            }
        }

#34793
Nov 16, 2009 17:06
* 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.