3

I don't understand why this happens. I added the following code into my ASP.NET project and it worked just fine several days ago. I then continued on working on the page until today I tried clicking the "Verify" button from the code below and here's what happens:

First this is the asp.net code:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
 <ContentTemplate>
  <asp:TextBox ID="TextVerifyName" runat="server" CssClass="input1" EnableViewState="false"></asp:TextBox>
  <asp:Button ID="ButtonVerifyName" runat="server" Text="Verify" CssClass="checkButton" onclick="ButtonVerifyName_Click" />
  <asp:UpdateProgress ID="UpdateProgressVerifyName" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
   <ProgressTemplate>
    <img src="Graphics/spinner.gif" alt="Please wait" />
   </ProgressTemplate>
  </asp:UpdateProgress>
 </ContentTemplate>
</asp:UpdatePanel>
  1. The first time I click the "Verify" button the code works fine.
  2. The second time I run it I get the following error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: 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.

Can someone explain why is this happening because the error message above is nothing more than 100% confusing???
I haven't done anything with ClientScriptManager.RegisterForEventValidation method.

3 Answers 3

3

Try putting any function/binding you have specified in the page_load event inside

if(!IsPostback)
{

}

It may help.

Sign up to request clarification or add additional context in comments.

Comments

2

Indeed, I was loading data in the Page_Load method but what was weird was that when you click on a grid that had a leaping commandColumn runtime error javascript. The solution was the

(! IsPostBack)
{
/ / loadData
}

Comments

0

Believe it or not, it took me half a day to find the cause for this error. So maybe someone can give me a reasonable explanation of how are these two connected?

Somewhere in the code during the page load event I was setting up a DropDownList control by adding items to it like so:

DropDownList1.Items.Add(new ListItem("Name", "Value"));

This is an aspx code for it:

<asp:DropDownList ID="DropDownList1" runat="server" EnableViewState="false"></asp:DropDownList>

So if I remove EnableViewState="false" from the tag above the error message that is in a totally unrelated area (i.e. updatePanel) goes away.

Any idea how two are connected????

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.