0
votes

Code like this with button in footer template after clicking that button error appears:

<asp:Repeater runat="server" ID="RptrDetailsSideList" OnItemCommand='rptMyRepeater_ItemCommand'>
   <ItemTemplate>
      <li  class="clearfix">
         <div class="art-thumb">
            <img src='<%#DataBinder.Eval(Container.DataItem, "listimage")%>' width="50" height="50" alt='<%#DataBinder.Eval(Container.DataItem, "listimagealt")%>' />
         </div>

         <div class="art-desc">
            <time datetime="2011-08-27T13:30+00:00"></time>
            <h3><a href="article.aspx?title=<%#DataBinder.Eval(Container.DataItem, "title")%>"><%#DataBinder.Eval(Container.DataItem, "listtile")%></a></h3>
            <p><%#DataBinder.Eval(Container.DataItem, "listdescription")%></p>
         </div>
      </li>
   </ItemTemplate>
   <FooterTemplate>
      <asp:Button runat="server" ID="btnRepeater" Text="TEST" CommandName='SomeAction' CommandArgument='100'/>
      </ul>
   </FooterTemplate>
</asp:Repeater>

The error is:

System.ArgumentException: 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.

Code for server side:

protected void rptMyRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    int x = 0;
}

What am I doing wrong ?

1
upload the code for rptMyRepeater_ItemCommand - Royi Namir
protected void rptMyRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { int x = 0; } - gruber
this is caused by adding elements ( maybe ajax) which was not when the page originated. - Royi Namir
show the page source ( view source) and paste it here. you might inject some elements which case this error. - Royi Namir
you can solve it by <pages enableEventValidation="false"/> but it aint the correct way. - Royi Namir

1 Answers