使用iFrame導致Invalid postback or callback argument.的解決方式

  • 257
  • 0

<iframe />導致拋出例外:ArgumentException: Invalid postback or callback argument.

問題:
在aspx檔中加入下列iframe標籤,觸發Button的onClick事件後,拋出例外:ArgumentException: Invalid postback or callback argument.

<iframe id="iframe1" src="http://bing.com" width="500" height="500"/>

解決之道:
將iframe標籤由單一標籤改為一對標籤。

<iframe id="iframe1" src="http://bing.com" width="500" height="500"></iframe>

參考資料:
[1]Invalid postback or callback argument. Error !!!
http://codeverge.com/asp.net.web-forms/invalid-postback-or-callback-argument-error/431645

[2]ClientScriptManager.RegisterForEventValidation Method (String)
https://msdn.microsoft.com/en-us/library/ms223397(v=vs.110).aspx


[3]Page.EnableEventValidation Property
https://msdn.microsoft.com/en-us/library/system.web.ui.page.enableeventvalidation(v=vs.110).aspx

[4]“Invalid postback or callback argument” in ASP.NET
https://blogs.msdn.microsoft.com/carloc/2008/05/02/invalid-postback-or-callback-argument-in-asp-net/

[5]KB-About Event Validation of ASP.NET 2.0
http://blog.darkthread.net/post-2008-05-13-kb-about-event-validation-of-asp-net-2-0.aspx