I have a Web Part which is using SPSecurity.RunWithElevatedPrivileges, and thus needs to call SPUtility.ValidateFormDigest. However, this apparently causes it to ignore all ASP.Net validators server side. The validation functions are being called, but the IsValid result seems to be either overwritten or ignored. What is causing this, and how do I fix it?

Broadly speaking, I have a Visual Web Part that is a form. It has a bunch of input controls, with various required, regular expression, and custom validators. And basically:

protected void SubmitButton_Click(object sender, EventArgs e)
         delegate { do a bunch of stuff including creating list items });

but a lot more complicated because there are a bunch of views and different submit buttons.

Originally I had SPUtility.ValidateFormDigest(); in Page_Load. I have also tried placing it directly before the SPSecurity.RunWithElevatedPrivileges in the click event handler, but that has not resolved the issue.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.