This is a migrated thread and some comments may be shown as answers.

Invalid postback or callback argument.

2 Answers 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
GarryP
Top achievements
Rank 1
GarryP asked on 12 Feb 2009, 12:38 PM
Hi,

When i click an Image button on a radgrid, I got a msgbox to test 

 Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid1.ItemCommand


if e.CommandName = "Release" then

msgbox("Release")

endif

end sub

But when i click i get the following error message.

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.

Thanks

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Feb 2009, 05:01 AM
Hi GarryP,

I have found the following forum link which discusses a similar issue. Go through it and see if it helps.
error when using ButtonType="ImageButton"

Shinu



0
TonyG
Top achievements
Rank 1
answered on 01 Nov 2011, 08:29 AM
Just posting for posterity here. The solution I found has nothing to do with how the grid is bound.
I have a RadGrid with GridTemplateColumn, and ItemTemplate with ImageButton.
The issue that triggered the error for me is that each ImageButton had the same ID.
Forum threads can send you on a wild goose chase when they talk about:
- advanced databinding and NeedsDataSource
- ClientScriptManager.RegisterForEventValidation
- <%@ Page EnableEventValidation="true" %> (in the aspx page)
- <pages enableEventValidation="true"/> (in web.config)

In my grid_ItemDataBound event I now have code like this:

if ( e.Item is GridDataItem )  {
 GridDataItem item = (GridDataItem) e.Item;
  ImageButton btn = (ImageButton) item.Cells[ 3 ].Controls[ 1 ];
  btn.ID = "btnR" + e.Item.ItemIndex; // this is the one-line fix
  ...
}

HTH
Tags
Grid
Asked by
GarryP
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
TonyG
Top achievements
Rank 1
Share this question
or