hi, i converted my project from asp.net 1.1 to 2.0 by Visual studio 2005 wizard. when i using my datagrid selected index event in asp.net 1.1(VS2003) it works fine. but after conversion it gives me the following error on selecting any item in grid.
Invalid postback or callback argument. Event validation is enabled using in configuration or 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 in configuration or 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 made enableEventValidation="true" in the page, but my team member told me that this will not recomemded its security in concern. Should there is any other way to solve this problem?
Well if you posting XML to a page or something like that with different tags that warning will show and you'll have to use enableEventValidation="true" to disable it. What are you posting? You can enable trace to see the request data.
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) +261 System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +83 System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection) +89 System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +36 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +479
I am uncertain what the stack trace information is telling me. I am somewhat new to .net and programming in general so any hints or tips that anyone can give would be helpful.
This is usually because of the ASP.NET Event Validation. Try setting EnableEventValidation to "false" in the page directive. For more details, you can check this long thread:
Zhao Ji Ma
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
We had the same problem in our project. The reason was we had a logic where we dynamically add controls to a table.
We had a textbox with the name txtProduct.We had a table with runat="server". In some cases we dont add this txt product to the table. In such cases we add a hidden variable with the same name "txtProduct" . So in a post back asp.Net constructs the page.
It tries to get the values for the textbox(TxtProduct) . since it has some other variable with the same name, we get the exception. Once we took out the hidden variable the problem was solved.
I also had this same error. After a bit of investigation, it was because I had ASP.NET set to 2.0 instead of 1.1 in my IIS server settings. Before hacking away at your code, be sure your ASP.NET framework is set correctly!
Well I had the same issue.In my case I was having a server image button in my datagrid as one of the column and was attaching javascript function to the image dynamically in codebehind.Now on the click of the image button I was doing a async postback using
update panel.
I received the same error whenever I clicked the Image .I just added "return false();" to my javascript function that I was adding dynamically to the image button and it worked like a charm without even adding the
enablepageeventvalidation = false.
hi,when I used,enableeventvalidation=false,in my .asp page,my gridview's selected index changed event is not getting fired.Can any one help me out why is it not getting fired.
Hi, I had the same issue, where I had a datalist with an Image Button. I was using the ItemCreated/ItemDataBound to set the ImageUrl of the image. I also did not have my databinding code in a if(!Page.IsPostBack). Once I changed my asp.net html code to
be <asp:ImageButton ID="btn" runat="server" ImageUrl='<%# Container.DataItem %>'> It worked fine. I think you have to be careful how your datagrid is bound.
I had an experience with DataGrid. One of it's columns was "Select" button. When I was clicking "Select" button of any row I had received this error message: "Invalid postback or callback argument. Event validation is enabled using in configuration or 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 changed several codes, finally I succeeded. my experience route:
1: I changed page attribute to EnableEventValidation="false". But it didn't work.
( not only is this dangerous for security reason, my event handler wasn't called:" void Grid_SelectedIndexChanged(object sender, EventArgs e)")
2: I implemented ClientScript.RegisterForEventValidation in Render method. But it didn't work.
protected override void Render(HtmlTextWriter writer) { foreach (DataGridItem item in this.Grid.Items) { Page.ClientScript.RegisterForEventValidation(item.UniqueID); foreach (TableCell cell in (item as TableRow).Cells) { Page.ClientScript.RegisterForEventValidation(cell.UniqueID);
foreach (System.Web.UI.Control control in cell.Controls) { if (control is Button) Page.ClientScript.RegisterForEventValidation(control.UniqueID); } } } }
3: I changed my button type in grid column from "PushButton" to "LinkButton".
It worked!
("<asp:ButtonColumn ButtonType="LinkButton" CommandName="Select"></asp:ButtonColumn>") I think if you can change your button to other controls like "LinkButton" in other cases, it would work properly.
First Google result so i'll add one for "if(!Page.IsPostBack)" in codebehind. I had a repeater with a databound imagebutton. When the button is clicked it threw that error. I finally realized that was trying to rebind my datasource on every postback. It's amazing
what staring at your code for 15 minutes can do.
Not sure if this helps but I just made a break through with this error after quite literally trawling the web for answers.
On my page I had 3 gridviews displaying different information, on one grid I wanted a link to post another page using postbackurl which carried the form values across.
It turned out that turning off the view state on the other grids allowed the postback to function.
None
0 Points
4 Posts
Invalid postback or callback argument
May 19, 2007 05:41 AM|sanjayvishu|LINK
hi, i converted my project from asp.net 1.1 to 2.0 by Visual studio 2005 wizard. when i using my datagrid selected index event in asp.net 1.1(VS2003) it works fine. but after conversion it gives me the following error on selecting any item in grid.
Invalid postback or callback argument. Event validation is enabled using in configuration or 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 in configuration or 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 made enableEventValidation="true" in the page, but my team member told me that this will not recomemded its security in concern. Should there is any other way to solve this problem?
Contributor
5578 Points
3325 Posts
MVP
Re: Invalid postback or callback argument
May 19, 2007 11:20 AM|albertpascual|LINK
Well if you posting XML to a page or something like that with different tags that warning will show and you'll have to use enableEventValidation="true" to disable it. What are you posting? You can enable trace to see the request data.
Al
My Blog
Member
1 Points
29 Posts
Re: Invalid postback or callback argument
May 21, 2007 10:14 AM|ScreamForMe|LINK
I am receiving the exact same error message:
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:
I am uncertain what the stack trace information is telling me. I am somewhat new to .net and programming in general so any hints or tips that anyone can give would be helpful.
All-Star
18654 Points
2312 Posts
Re: Invalid postback or callback argument
Jul 30, 2007 03:09 AM|Zhao Ji Ma - MSFT|LINK
Hi,
This is usually because of the ASP.NET Event Validation. Try setting EnableEventValidation to "false" in the page directive. For more details, you can check this long thread:
http://forums.asp.net/t/922994.aspx?PageIndex=1
Hope it helps.
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
None
0 Points
1 Post
Re: Invalid postback or callback argument
Sep 05, 2007 01:42 AM|tourams|LINK
We had the same problem in our project. The reason was we had a logic where we dynamically add controls to a table.
We had a textbox with the name txtProduct.We had a table with runat="server". In some cases we dont add this txt product to the table. In such cases we add a hidden variable with the same name "txtProduct" . So in a post back asp.Net constructs the page. It tries to get the values for the textbox(TxtProduct) . since it has some other variable with the same name, we get the exception. Once we took out the hidden variable the problem was solved.
Member
10 Points
1 Post
Re: Invalid postback or callback argument
Sep 12, 2007 05:52 PM|aaronjlewis@hotmail.com|LINK
I also had this same error. After a bit of investigation, it was because I had ASP.NET set to 2.0 instead of 1.1 in my IIS server settings. Before hacking away at your code, be sure your ASP.NET framework is set correctly!
None
0 Points
1 Post
Re: Invalid postback or callback argument
Feb 27, 2008 04:19 PM|Prashushetty2277|LINK
Well I had the same issue.In my case I was having a server image button in my datagrid as one of the column and was attaching javascript function to the image dynamically in codebehind.Now on the click of the image button I was doing a async postback using update panel.
I received the same error whenever I clicked the Image .I just added "return false();" to my javascript function that I was adding dynamically to the image button and it worked like a charm without even adding the enablepageeventvalidation = false.
Member
3 Points
41 Posts
Re: Invalid postback or callback argument
May 02, 2008 01:37 PM|jaqs|LINK
where do i add enablepageeventvalidation=false? I'm getting this same error and i really want to get rid of it.
Thanks
Contributor
5578 Points
3325 Posts
MVP
Re: Invalid postback or callback argument
May 03, 2008 12:43 PM|albertpascual|LINK
on the page definition after @Page on the aspx file first line.
Al
My Blog
None
0 Points
30 Posts
Re: Invalid postback or callback argument
May 28, 2008 07:12 PM|invent|LINK
hi,when I used,enableeventvalidation=false,in my .asp page,my gridview's selected index changed event is not getting fired.Can any one help me out why is it not getting fired.
None
0 Points
3 Posts
Re: Invalid postback or callback argument
Jun 07, 2008 03:03 AM|mangokun|LINK
http://aspnet.4guysfromrolla.com/demos/printPage.aspx?path=/articles/122006-1.aspx
</div>Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
'###this removes the no forms error by overriding the error
End Sub
Public Overrides Property EnableEventValidation() As Boolean
Get
Return False
End Get
Set(ByVal value As Boolean)
'DO NOTHING
End Set
End Property
http://www.geocities.com/mangokun/
Bring on the black and white
http://www.imdb.com/title/tt0388556/
None
0 Points
1 Post
Re: Invalid postback or callback argument
Oct 21, 2008 06:11 PM|jbarber2008|LINK
None
0 Points
1 Post
Re: Invalid postback or callback argument
Nov 09, 2008 03:19 AM|AmirPalang|LINK
I had an experience with DataGrid. One of it's columns was "Select" button. When I was clicking "Select" button of any row I had received this error message: "Invalid postback or callback argument. Event validation is enabled using in configuration or 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 changed several codes, finally I succeeded. my experience route:
1: I changed page attribute to EnableEventValidation="false". But it didn't work.
( not only is this dangerous for security reason, my event handler wasn't called:" void Grid_SelectedIndexChanged(object sender, EventArgs e)")
2: I implemented ClientScript.RegisterForEventValidation in Render method. But it didn't work.
protected override void Render(HtmlTextWriter writer) { foreach (DataGridItem item in this.Grid.Items) { Page.ClientScript.RegisterForEventValidation(item.UniqueID); foreach (TableCell cell in (item as TableRow).Cells) { Page.ClientScript.RegisterForEventValidation(cell.UniqueID); foreach (System.Web.UI.Control control in cell.Controls) { if (control is Button) Page.ClientScript.RegisterForEventValidation(control.UniqueID); } } } }
3: I changed my button type in grid column from "PushButton" to "LinkButton". It worked!
("<asp:ButtonColumn ButtonType="LinkButton" CommandName="Select"></asp:ButtonColumn>") I think if you can change your button to other controls like "LinkButton" in other cases, it would work properly.
Member
20 Points
4 Posts
Re: Invalid postback or callback argument
Dec 06, 2008 04:43 PM|chtvn|LINK
oh the solution for this is that "Bind data in the (!isPostBack)" (cannot believe but it does work :-( )
should write smt like
Member
10 Points
12 Posts
Re: Invalid postback or callback argument
Jan 08, 2009 07:41 AM|savindra.bandi|LINK
set EnableEventValidation="false" in the page directive
<%@ Page Language="C#" EnableEventValidation="false" %>
None
0 Points
1 Post
Re: Invalid postback or callback argument
Jan 09, 2009 03:42 AM|Reason Man|LINK
None
0 Points
3 Posts
Re: Invalid postback or callback argument
Jan 15, 2009 06:10 PM|bobster9999|LINK
Not sure if this helps but I just made a break through with this error after quite literally trawling the web for answers.
On my page I had 3 gridviews displaying different information, on one grid I wanted a link to post another page using postbackurl which carried the form values across.
It turned out that turning off the view state on the other grids allowed the postback to function.
Hope this helps anyone.
IIS7 / .NET 2 / VS2008