tags:

views:

410

answers:

2

I have a Repeater with a Button inside the ItemTemplate. I added the CommandName property to the button and registered and event handler for the ItemCommand event on the Repeater.

My problem is that when I click the button, I get an ArgumentException with a message saying something about EnableEventValidation being set to true.

(By the way, is there a way I can get the message in English, instead of a lousy Portuguese translation?)

I tried setting it to false and the ItemCommand handler is not called. If I set it to true I get the error.

The message also says something about using ClientScriptManager.RegisterForEventValidation if I trust the client (which I do). The problem is I can't make sense of the documentation for that method.

+1  A: 

The only time I've ever seen this is when I was rebinding the repeater in the Page_Load on postback, rather than wrapping the binding in an if (!Page.IsPostBack). If you do this then the control that's sending the message is effectively invalid, so it fails.

Steven Robbins
+2  A: 

lookout for the binding problem pointed out by Steve Robbins and you may also want to take a look at this article which I found pretty useful when I was stuck in a similar situation.

Perpetualcoder
Thanks. That solves it. Though the code is in VB, but I managed.
Martinho Fernandes
VB is not my language of choice but I try to work around it. Glad I was of help.
Perpetualcoder