PageRequestManagerServerErrorException with asp:GridViewPagerhttp://forums.asp.net/t/1419087.aspx/1?PageRequestManagerServerErrorException+with+asp+GridViewPagerFri, 13 Jul 2012 01:43:48 -040014190873141207http://forums.asp.net/p/1419087/3141207.aspx/1?PageRequestManagerServerErrorException+with+asp+GridViewPagerPageRequestManagerServerErrorException with asp:GridViewPager <p>I have developed an ASP.NET Dynamic Data site that also contains some custom pages using the DD features.</p> <p>&nbsp;The site has been working fine for weeks, but all of a sudden this morning on one Page I am receiving the error:</p> <p>Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.&nbsp;...</p> <p>This happens when I try and click the Next or Last button or try and change the page number on a asp:GridViewPager supplied as part of DD.&nbsp; This page has been working fine with multiple pages up until today.</p> <p>This system is now live, so I would love any help or direction you can provide.&nbsp; Code inline below:</p> <p>Default.aspx:</p> <p>&nbsp;<pre class="prettyprint">&lt;%@ Page Language=&quot;C#&quot; MasterPageFile=&quot;~/Requests.master&quot; CodeFile=&quot;Default.aspx.cs&quot; Inherits=&quot;ListRequests&quot; %&gt; &lt;%@ Register src=&quot;~/DynamicData/Content/GridViewPager.ascx&quot; tagname=&quot;GridViewPager&quot; tagprefix=&quot;asp&quot; %&gt; &lt;%@ Register src=&quot;~/DynamicData/Content/FilterUserControl.ascx&quot; tagname=&quot;DynamicFilter&quot; tagprefix=&quot;asp&quot; %&gt; &lt;asp:Content ID=&quot;Content1&quot; ContentPlaceHolderID=&quot;ContentPlaceHolder1&quot; Runat=&quot;Server&quot;&gt; &lt;asp:DynamicDataManager ID=&quot;DynamicDataManager1&quot; runat=&quot;server&quot; AutoLoadForeignKeys=&quot;true&quot; /&gt; &lt;h2&gt;Your Virtual Server requests&lt;/h2&gt; &lt;p&gt;Only requests for user &lt;asp:Label ID=&quot;labelUser&quot; runat=&quot;server&quot; Font-Bold=&quot;True&quot; /&gt; are show below.&lt;/p&gt; &lt;p&gt;Use the search function to find requests you did not submit.&lt;/p&gt; &lt;asp:ScriptManagerProxy runat=&quot;server&quot; ID=&quot;ScriptManagerProxy1&quot; /&gt; &lt;asp:UpdatePanel ID=&quot;UpdatePanel1&quot; runat=&quot;server&quot;&gt; &lt;ContentTemplate&gt; &lt;asp:ValidationSummary ID=&quot;ValidationSummary1&quot; runat=&quot;server&quot; EnableClientScript=&quot;true&quot; HeaderText=&quot;List of validation errors&quot; /&gt; &lt;asp:DynamicValidator runat=&quot;server&quot; ID=&quot;GridViewValidator&quot; ControlToValidate=&quot;GridView1&quot; Display=&quot;None&quot; /&gt; &lt;asp:GridView ID=&quot;GridView1&quot; runat=&quot;server&quot; AllowPaging=&quot;True&quot; AllowSorting=&quot;True&quot; CssClass=&quot;gridview&quot;&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:HyperLink ID=&quot;DetailsHyperLink&quot; runat=&quot;server&quot; NavigateUrl='&lt;%# &quot;/VRM/requests/ViewRequest.aspx?id=&quot; &#43; Eval(&quot;Request_id&quot;) %&gt;' Text=&quot;Details&quot; /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;PagerStyle CssClass=&quot;footer&quot;/&gt; &lt;PagerTemplate&gt; &lt;asp:GridViewPager runat=&quot;server&quot; /&gt; &lt;/PagerTemplate&gt; &lt;EmptyDataTemplate&gt; You have not yet submitted any requests. &lt;/EmptyDataTemplate&gt; &lt;/asp:GridView&gt; &lt;br /&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;/asp:Content&gt;</pre> <P>&nbsp;Default.aspx.cs</P><pre class="prettyprint"><SPAN class=kwd>using</SPAN> System; <SPAN class=kwd>using</SPAN> System.Data; <SPAN class=kwd>using</SPAN> System.Configuration; <SPAN class=kwd>using</SPAN> System.Collections; <SPAN class=kwd>using</SPAN> System.Linq; <SPAN class=kwd>using</SPAN> System.Web; <SPAN class=kwd>using</SPAN> System.Web.Security; <SPAN class=kwd>using</SPAN> System.Web.UI; <SPAN class=kwd>using</SPAN> System.Web.UI.WebControls; <SPAN class=kwd>using</SPAN> System.Web.UI.WebControls.WebParts; <SPAN class=kwd>using</SPAN> System.Web.UI.HtmlControls; <SPAN class=kwd>using</SPAN> System.Xml.Linq; <SPAN class=kwd>using</SPAN> System.Web.DynamicData; <SPAN class=kwd>public</SPAN> partial <SPAN class=kwd>class</SPAN> ListRequests : System.Web.UI.Page { <SPAN class=kwd>protected void</SPAN> Page_PreInit(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { <SPAN class=kwd>this</SPAN>.MasterPageFile = AppHelpers.DynamicMaster(); } <SPAN class=kwd>protected void</SPAN> Page_Init(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { DynamicDataManager1.RegisterControl(GridView1, <SPAN class=kwd>true</SPAN> <SPAN class=cmt>/*setSelectionFromUrl*/</SPAN>); } <SPAN class=kwd>protected void</SPAN> Page_Load(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { VRMDataContext db = <SPAN class=kwd>new</SPAN> VRMDataContext(); var rows = from p <SPAN class=kwd>in</SPAN> db.Requests where p.RequesterLogon.Equals(AppHelpers.CurrentUser()) orderby p.RequestDate descending select <SPAN class=kwd>new</SPAN> { Request_ID = p.id, Server_Name = p.ServerName, Date_Requested = p.RequestDate, Stage = p.RequestStage.Name, Environment = p.Environment.Name, Location = p.Location.Name, PU = p.PUperCPU, CPUs = p.NumCPUs, Replicated = p.Replicated, LUN = p.LUNsize }; GridView1.DataSource = rows; GridView1.DataBind(); labelUser.Text = AppHelpers.CurrentUser(); } <SPAN class=kwd>protected void</SPAN> OnFilterSelectedIndexChanged(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { GridView1.PageIndex = 0; } }</pre>&nbsp;</p> 2009-05-05T10:35:49-04:003141453http://forums.asp.net/p/1419087/3141453.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Can you paste in the full yellow screen (you may need to turn EnablePartialRendering=&quot;true&quot; to false in the Site.Master Page to see the full error)</p> 2009-05-05T12:14:04-04:003141572http://forums.asp.net/p/1419087/3141572.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Hi Steve</p> <p>&nbsp;I'm not actually getting a Yellow Screen.&nbsp; Originally I had Custom errors enabled in the web.config and the site was catching the exception.</p> <p>I changed the CustomErrors setting to Off, and now rather than throwing an exception at the server level, it is throwing a local javascript error.&nbsp; You get the little yellow triangle in the bottom left and I guess this is because Javascript is doing the Postback.</p> <p>The full error text from the Javascript dialog is:</p> <p>Line: 4724<br> Char: 21<br> Error: sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.&nbsp; Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration or &lt;%@ Page EnabledEventValidation=&quot;true&quot; %&gt; in a page.&nbsp; For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.&nbsp; If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.<br> Code: 0<br> URL: <a href="http://www.myurl.com/VRM/Requests/Default.aspx">http://www.myurl.com/VRM/Requests/Default.aspx</a></p> <p>Thanks</p> <p>Steve<br> </p> 2009-05-05T12:49:19-04:003141616http://forums.asp.net/p/1419087/3141616.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Hi Steve, the local javascript error is due to PartialRendering you will need to turn EnablePartialRendering=&quot;true&quot; to false in the Site.Master Page to see the full error thanks.</p> 2009-05-05T12:59:54-04:003141658http://forums.asp.net/p/1419087/3141658.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Ah ok.&nbsp; Sorry.</p> <p>Here is the output from the error with Partial Page Rendering disabled:</p> <h1>Server Error in '/VRM' Application. </h1> <hr size="0"> <p>&nbsp;</p> <i> <h2>Invalid postback or callback argument. Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration or &lt;%@ Page EnableEventValidation=&quot;true&quot; %&gt; 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.</i> </h2> <b><font face="Arial, Helvetica"> <p>Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br> <br> <b>Exception Details: </b>System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration or &lt;%@ Page EnableEventValidation=&quot;true&quot; %&gt; 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.<br> <br> <b>Source Error:</b> <br> </p> </font> <table dir="ltr" border="0" cellspacing="0" width="624"> <tbody> <tr> <td bgcolor="#ffff00" valign="center"><pre class="prettyprint"><p>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</p></pre><FONT face="Arial, Helvetica"> </FONT></P></TD></TR></TBODY></TABLE><FONT face="Arial, Helvetica"></FONT></FONT><FONT face="Arial, Helvetica"> <P><BR><B>Stack Trace:</B> <BR></P> <P mce_keep="true"></FONT> <TABLE dir=ltr border=0 cellSpacing=0 width=624> <TBODY> <TR> <TD bgColor=#ffff00 vAlign=center><pre class="prettyprint"><PRE>[ArgumentException: Invalid postback or callback argument. Event validation is enabled using &lt;pages enableEventValidation="true"/&gt; in configuration or &lt;%@ Page EnableEventValidation="true" %&gt; 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.] System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +8620921 System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +72 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +35 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565</PRE></pre></td> </tr> </tbody> </table> <p></p> 2009-05-05T13:12:31-04:003141735http://forums.asp.net/p/1419087/3141735.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>&lt;%@ Page EnableEventValidation=&quot;false&quot; %&gt;</p> <p>Try adding EnableEventValidation=&quot;false&quot; in th <a href="mailto:e@Page">e@Page</a> directive JUST FOR TESTING incase this is masking an underlying error [:D]</p> 2009-05-05T13:35:05-04:003141777http://forums.asp.net/p/1419087/3141777.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Ok Steve, I tried that.</p> <p>&nbsp;It now doesn't throw an exception or any errors but the Page doesn't change (actually a blank line appers below the pager)&nbsp;.&nbsp; It does postback but nothing happens.</p> <p>This is really strange.</p> <p>Thanks</p> <p>Steve</p> 2009-05-05T13:50:20-04:003141805http://forums.asp.net/p/1419087/3141805.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Steve</p> <p>Looks like I am wrong, this has never worked.&nbsp; I tested it on preprod with different data and got the same result once I got past 10 entries.&nbsp; I have lots of similar pages that all work, so I mixed it up with one of those.</p> <p>It must be the way I am setting the data in the PageLoad event.&nbsp; I think I set it in the Selecting event of the Datagrid elsewhere.</p> <p>I'll try that.&nbsp; Sorry for the trouble.</p> <p>Steve</p> 2009-05-05T13:59:18-04:003141851http://forums.asp.net/p/1419087/3141851.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>&nbsp;the error is due to ....</p> <p>ur postback was not send to the server&nbsp; properly, hence the page was not retriewd and u got the execption..</p> <p>please wait for the complete postback..wait until all the data gets displayed in the gridview..check ur progress bar below the browser and click the button aftr all process is completed...</p> <p>u r getting this error bcoz while data is been retriewing from SQl server u r trying to do next process..</p> <p>i was also getting the same error..i need to display 100 data in gridview . and i used to click the button before all the data was displayed...i didnt got the solution ..so i used pagging function... <br> </p> 2009-05-05T14:12:54-04:003141910http://forums.asp.net/p/1419087/3141910.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Hi</p> <p>&nbsp;</p> <p>All the data in the grid had loaded and was displayed long before I clicked any of the Paging buttons.</p> <p>The error is because I am setting the Datagrid data programatically as part of the Page_Load event.</p> <p>Everywhere else on the site I bind the Datagrid to a DataSourceControl then trap the Selecting event of the DataSource and set the e.result property to the data returned.</p> <p>I changed this page to do the same and now it is working fine.&nbsp; I guess it doesn't like you setting the DataGrid in the Page_Load event.</p> <p>Thanks</p> <p>Steve</p> 2009-05-05T14:33:09-04:003142159http://forums.asp.net/p/1419087/3142159.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Excelent Steve, [:D] glad it's working now.</p> 2009-05-05T15:53:29-04:004975884http://forums.asp.net/p/1419087/4975884.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>Thanks a lot Steve :)</p> <p>You have saved me from this hell out Issue.&nbsp;</p> <p>I was googling for this for the past 2 days, but couldn't help myself..</p> <p>Your solution has worked like magic :)</p> <p>----------------------------------------------</p> <p>Removed dataBinding from Page_load !!!</p> <p></p> 2012-05-11T06:23:23-04:005064290http://forums.asp.net/p/1419087/5064290.aspx/1?Re+PageRequestManagerServerErrorException+with+asp+GridViewPagerRe: PageRequestManagerServerErrorException with asp:GridViewPager <p>try to put your binding in page_load inside if(!ispostback){ bindToGrid();}</p> 2012-07-13T01:43:48-04:00