consultancy chorley ASP.NET Server Side Scripting Wigan
Website Development Radcliffe

IT Services And Support

Email :
Mobile Phone : 0788 68 41 411
Answerphone : 01204 469683
bespoke invoice systems Standish Information Technology Advice Worsley
    development systems Ramsbottom
data manipulation Farnworth access databases Whitefield SQL connections Atherton
online accessible software Leyland software compatible Coppull

Get connected and Online Tottington
remote management Makerfield code and design Aspull

Invalid postback or callback argument. Event validation is enabled...ASP.Net Error - 12/04/2011

So You've Got...

Server Error in '/' Application.
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.


Here's a shortened version of the offending code...

sub page_load
  dim qwe as string = "SELECT * FROM mytable"

 ........sql stuff to populate a repeater, datagrid etc

end sub

sub dochange(sender as object, e as eventargs)
  Dim btn As Button = sender
 dim namef as textbox = btn.parent.findcontrol("namef")
 dim phonef as textbox = btn.parent.findcontrol("phonef")
 dim uidf as textbox = btn.parent.findcontrol("uidf") stuff with the button click
end sub

.....html stuff....

<asp:repeater id = "mygrid" runat = "server">

<asp:textbox id = "namef" text = '<%# container.dataitem("namef") %>' runat = "server" />

<asp:textbox id = "phonef" text = '<%# container.dataitem("phonef") %>' runat = "server" />

<asp:textbox id = "uidf" text = '<%# container.dataitem("uidf") %>' runat = "server" visible = "false" />

<asp:button text = "Update" onclick = "doupdate" runat = "server" />

<asp:button onclick = "dodelete"
            text = "Delete"
            OnClientClick = "return confirm('Are you sure you want to delete this Record?')"
            runat = "server"




What's happening here.  Note the page loads and creates the repeater or datagrid or whatever populateable control you're using.  In this control you create a button, one for each repetition or row.  When you click the button it bombs...why?

Because you numpty...THE PAGE IS RELOADING!  So each time the page is reloaded it's recreating the control AND trying to find the button at the same time.  Simple add a "if not page.ispostback"

Just remember...

if not page.ispostback

I can't believe I missed that...

Post A Comment

Name Comment
programming services specialist
Valid XHTML 1.0 Transitional