1

I am receiving this error when I click on the button to log into Facebook from my website.

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.

When searched Google and found these two links so I can understand the error message. However they did not fix the problem.

asp.net: Invalid postback or callback argument

http://blogs.msdn.com/b/amitsh/archive/2007/07/31/why-i-get-invalid-postback-or-callback-argument-errors.aspx

So I took apart the page section by section until I found what was causing the error. It was this:

iframe name="ContentIFrame" class="IFrameStyle"

When I delete the iframe, everything works. However, I need the iframe on the page. Can anyone assist why the iframe is causing this error? It has nothing to do with Postback.

Community
  • 1
  • 1
Dan Nick
  • 514
  • 1
  • 9
  • 30

1 Answers1

0

While I have seen suggestions to disable event validation (setting EnableEventValidation=false), I do not recommend that approach as it could create security problems. In my case, what resolved the problem was to use an asp:PlaceHolder instead of directly placing the iframe into the ASPX. Then, in the C# code, I add a new HtmlIframe control to the placeholder's ControlCollection:

Place the following in the ASPX:

<asp:PlaceHolder runat="server" ID="myPlaceholder" />

Then, place the following in the postback handler:

using System.Web.UI.HtmlControls;

HtmlIframe newIframe = new HtmlIframe();
newIframe.Src = "somewhere/some_page.html";
myPlaceholder.Controls.Add(newIframe);

An alternative is to place the iframe directly into the ASPX and to set the HTML element as runat="server". Once runat="server" has been set, you should be able to access the control's ID from within your code to set the src attribute.

Michael
  • 2,268
  • 20
  • 24