14 July 2006

WSS2 SP2 and .NET 2 Bug

A few weeks ago I was surprised by a very annoying bug in Windows SharePoint Services SP2 running under .NET Framework 2.0. When a page is customized with FrontPage (in this case the layout of the page is stored in SQL Server) and web part compiled with .NET 2.0 is imported to this page, the following exception is thrown:

Invalid postback or callback argument. Event validation is enabled using
<pages enableEventValidation="true"/> in configuration or
<%@ Page EnableEventValidation="true" %> in a page. For security
purposes, this feature verifies that arguments to postback or callback events
originate from the server control that originally rendered them. If the data is
valid and expected, use the ClientScriptManager.RegisterForEventValidation
method in order to register the postback or callback data for validation.


After some quick and unsuccessful attempts to resolve the exception, rapid search in google proved that this is really a bug.

Fortunately this bug is not present in SharePoint 2007 Beta 2 (I have tested it).

2 comments:

Anonymous said...

Stephen, thank you for your post. This definitely appears to be an underdocumented issue. Even after reading your posts, however, I still cannot resolve this issue in a SharePoint 2007 WebPart. The WebPart has two System.Web.UI.DropDownList and one System.Web.UI.Button controls on it. All three of these support event validation. Before I use .RenderControl(output) in RenderWebPart I dynamically add the ListItems to the two DropDownList controls. As I add each value I do this.Page.ClientScript.RegisterForEventValidation(this.mydropdownlist.UniqueID, item.Value); for each value for each dropdownlist. However I still get the Invalid postback or callback argument. error. I've tried calling RegisterForEventValidation in RenderWebPart and in Render with no change. You said you tested this in MOSS Beta 2 (which is what I am using). Exactly how did you get it to work? Thank you again.

Stephan Zahariev said...

Hi Robin. Sorry for the delay, but I'm just returning from my summer holiday.
I'm not using ClientScript.RegisterForEventValidation in my web parts. I receive exception about event validation in WSS2 running under .NET Framework 2.0 for every webpart added to page.
What you say looks like another undocumented bug. Try to search for this issue.