I have developed an ASP.NET Dynamic Data site that also contains some custom pages using the DD features.
The site has been working fine for weeks, but all of a sudden this morning on one Page I am receiving the error:
Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument. ...
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. This page has been working fine with multiple pages up until today.
This system is now live, so I would love any help or direction you can provide. Code inline below:
Default.aspx:
<%@ Page Language="C#" MasterPageFile="~/Requests.master" CodeFile="Default.aspx.cs" Inherits="ListRequests" %>
<%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %>
<%@ Register src="~/DynamicData/Content/FilterUserControl.ascx" tagname="DynamicFilter" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />
<h2>Your Virtual Server requests</h2>
<p>Only requests for user <asp:Label ID="labelUser" runat="server" Font-Bold="True" /> are show below.</p>
<p>Use the search function to find requests you did not submit.</p>
<asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
HeaderText="List of validation errors" />
<asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" />
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AllowSorting="True" CssClass="gridview">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="DetailsHyperLink" runat="server"
NavigateUrl='<%# "/VRM/requests/ViewRequest.aspx?id=" + Eval("Request_id") %>'
Text="Details" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="footer"/>
<PagerTemplate>
<asp:GridViewPager runat="server" />
</PagerTemplate>
<EmptyDataTemplate>
You have not yet submitted any requests.
</EmptyDataTemplate>
</asp:GridView>
<br />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Web.DynamicData;
public partial class ListRequests : System.Web.UI.Page {
protected void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = AppHelpers.DynamicMaster();
}
protected void Page_Init(object sender, EventArgs e) {
DynamicDataManager1.RegisterControl(GridView1, true/*setSelectionFromUrl*/);
}
protected void Page_Load(object sender, EventArgs e) {
VRMDataContext db = new VRMDataContext();
var rows = from p in db.Requests
where p.RequesterLogon.Equals(AppHelpers.CurrentUser())
orderby p.RequestDate descending
select new
{
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();
}
protected void OnFilterSelectedIndexChanged(object sender, EventArgs e) {
GridView1.PageIndex = 0;
}
}
I'm not actually getting a Yellow Screen. Originally I had Custom errors enabled in the web.config and the site was catching the exception.
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. You get the little yellow triangle in the bottom left and I guess this is because Javascript is doing the
Postback.
The full error text from the Javascript dialog is:
Line: 4724
Char: 21
Error: sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnabledEventValidation="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.
Code: 0
URL: http://www.myurl.com/VRM/Requests/Default.aspx
Hi Steve, the local javascript error is due to PartialRendering you will need to turn EnablePartialRendering="true" to false in the Site.Master Page to see the full error thanks.
Dynamic Data
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Here is the output from the error with Partial Page Rendering disabled:
Server Error in '/VRM' 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.
Description:
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.
Exception Details: System.ArgumentException: 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.
Source Error:
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.
Stack Trace:
[ArgumentException: 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.]
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
It now doesn't throw an exception or any errors but the Page doesn't change (actually a blank line appers below the pager) . It does postback but nothing happens.
Looks like I am wrong, this has never worked. I tested it on preprod with different data and got the same result once I got past 10 entries. I have lots of similar pages that all work, so I mixed it up with one of those.
It must be the way I am setting the data in the PageLoad event. I think I set it in the Selecting event of the Datagrid elsewhere.
ur postback was not send to the server properly, hence the page was not retriewd and u got the execption..
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...
u r getting this error bcoz while data is been retriewing from SQl server u r trying to do next process..
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...
All the data in the grid had loaded and was displayed long before I clicked any of the Paging buttons.
The error is because I am setting the Datagrid data programatically as part of the Page_Load event.
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.
I changed this page to do the same and now it is working fine. I guess it doesn't like you setting the DataGrid in the Page_Load event.
Thanks
Steve
Marked as answer by sjnaughton on May 05, 2009 03:53 PM
steddyman
Member
23 Points
82 Posts
PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 10:35 AM|LINK
I have developed an ASP.NET Dynamic Data site that also contains some custom pages using the DD features.
The site has been working fine for weeks, but all of a sudden this morning on one Page I am receiving the error:
Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument. ...
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. This page has been working fine with multiple pages up until today.
This system is now live, so I would love any help or direction you can provide. Code inline below:
Default.aspx:
<%@ Page Language="C#" MasterPageFile="~/Requests.master" CodeFile="Default.aspx.cs" Inherits="ListRequests" %> <%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %> <%@ Register src="~/DynamicData/Content/FilterUserControl.ascx" tagname="DynamicFilter" tagprefix="asp" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" /> <h2>Your Virtual Server requests</h2> <p>Only requests for user <asp:Label ID="labelUser" runat="server" Font-Bold="True" /> are show below.</p> <p>Use the search function to find requests you did not submit.</p> <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true" HeaderText="List of validation errors" /> <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" /> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" CssClass="gridview"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:HyperLink ID="DetailsHyperLink" runat="server" NavigateUrl='<%# "/VRM/requests/ViewRequest.aspx?id=" + Eval("Request_id") %>' Text="Details" /> </ItemTemplate> </asp:TemplateField> </Columns> <PagerStyle CssClass="footer"/> <PagerTemplate> <asp:GridViewPager runat="server" /> </PagerTemplate> <EmptyDataTemplate> You have not yet submitted any requests. </EmptyDataTemplate> </asp:GridView> <br /> </ContentTemplate> </asp:UpdatePanel> </asp:Content>Default.aspx.cs
sjnaughton
All-Star
27391 Points
5485 Posts
MVP
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 12:14 PM|LINK
Can you paste in the full yellow screen (you may need to turn EnablePartialRendering="true" to false in the Site.Master Page to see the full error)
Dynamic Data
Always seeking an elegant solution.
steddyman
Member
23 Points
82 Posts
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 12:49 PM|LINK
Hi Steve
I'm not actually getting a Yellow Screen. Originally I had Custom errors enabled in the web.config and the site was catching the exception.
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. You get the little yellow triangle in the bottom left and I guess this is because Javascript is doing the Postback.
The full error text from the Javascript dialog is:
Line: 4724
Char: 21
Error: sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnabledEventValidation="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.
Code: 0
URL: http://www.myurl.com/VRM/Requests/Default.aspx
Thanks
Steve
sjnaughton
All-Star
27391 Points
5485 Posts
MVP
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 12:59 PM|LINK
Hi Steve, the local javascript error is due to PartialRendering you will need to turn EnablePartialRendering="true" to false in the Site.Master Page to see the full error thanks.
Dynamic Data
Always seeking an elegant solution.
steddyman
Member
23 Points
82 Posts
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 01:12 PM|LINK
Ah ok. Sorry.
Here is the output from the error with Partial Page Rendering disabled:
Server Error in '/VRM' 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.
Description:
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.Exception Details: System.ArgumentException: 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.
Source Error:
Stack Trace:
sjnaughton
All-Star
27391 Points
5485 Posts
MVP
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 01:35 PM|LINK
<%@ Page EnableEventValidation="false" %>
Try adding EnableEventValidation="false" in th e@Page directive JUST FOR TESTING incase this is masking an underlying error [:D]
Dynamic Data
Always seeking an elegant solution.
steddyman
Member
23 Points
82 Posts
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 01:50 PM|LINK
Ok Steve, I tried that.
It now doesn't throw an exception or any errors but the Page doesn't change (actually a blank line appers below the pager) . It does postback but nothing happens.
This is really strange.
Thanks
Steve
steddyman
Member
23 Points
82 Posts
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 01:59 PM|LINK
Steve
Looks like I am wrong, this has never worked. I tested it on preprod with different data and got the same result once I got past 10 entries. I have lots of similar pages that all work, so I mixed it up with one of those.
It must be the way I am setting the data in the PageLoad event. I think I set it in the Selecting event of the Datagrid elsewhere.
I'll try that. Sorry for the trouble.
Steve
Rangapure.S....
Participant
765 Points
237 Posts
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 02:12 PM|LINK
the error is due to ....
ur postback was not send to the server properly, hence the page was not retriewd and u got the execption..
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...
u r getting this error bcoz while data is been retriewing from SQl server u r trying to do next process..
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...
steddyman
Member
23 Points
82 Posts
Re: PageRequestManagerServerErrorException with asp:GridViewPager
May 05, 2009 02:33 PM|LINK
Hi
All the data in the grid had loaded and was displayed long before I clicked any of the Paging buttons.
The error is because I am setting the Datagrid data programatically as part of the Page_Load event.
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.
I changed this page to do the same and now it is working fine. I guess it doesn't like you setting the DataGrid in the Page_Load event.
Thanks
Steve