If you want to run some script before or after client validation has been performed, you'll need to redirect the WebForm_OnSubmit() function. Because of the framework we are using, WebForm_OnSubmit() was returning false immediately, so adding anything to Page.ClientScript.RegisterOnSubmitStatement was never being run.
I didn't have time to sort out where in the framework this was being set up (never mind the impact analysis), so I re-directed the Submit of the form to call my function first, then called the WebForm_OnSubmit code as normal.
if (!Page.ClientScript.IsClientScriptBlockRegistered(submitRedirect))
{
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.AppendFormat("var oldSubmit = document.getElementById('Form1').onsubmit;");
sb.Append("function mySubmit()");
sb.Append("{");
//Your code here
sb.Append("return oldSubmit();");
sb.Append("}");
sb.Append("document.getElementById('Form1').onsubmit = mySubmit;");
sb.Append("</script>");
Page.ClientScript.RegisterClientScriptBlock(GetType(),
submitRedirect, sb.ToString());
}
Thanks to http://forums.asp.net/p/1011848/1354154.aspx for this tip.