views:

480

answers:

1

Hi

I included a repeater in my master page. The repeater has a button that I set its CommandArgument.

However when I click the button I get the following exception:

System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using 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.


And it doesn't continue to the event handler.

Note: I tried adding these lines to the master page but it doesn't help:

protected override void Render(HtmlTextWriter writer)
{
    Page.ClientScript.RegisterForEventValidation(rptrLanguages.ClientID);
    base.Render(writer);
}

Thanks.

+2  A: 

Are you doing any databinding on that page? If so, is it happening between a check for !IsPostBack ?

if (!IsPostBack) { // do databinding }

A similar issue was mentioned here.

Ahmad Mageed
I wasted for this stupid thing so long :(Thanks man!
Shimmy
It wasn't a waste: you were waiting for Ahmad's answer, and now you have it, and won't make the same mistake again.
John Saunders