I have a composite control which consists of label, linkbutton & textbox control. Depending on the display mode (a property within the control) one of the control gets displayed. However when the linkbutton is clicked it seems to throw up this error. The control
works fine in .NET 1.1.
The control inherits from System.Web.UI.WebControls.WebControl, IPostBackDataHandler & INamingContainer & this is my IpostBackDataHandler implementation
if (!this.Text.Equals(postCollection[postDataKey]))
{
this.Text = postCollection[postDataKey];
retVal = true;
}
return retVal;
}
#endregion IPostBackDataHandler Implementation
#### ERROR BEGIN ####
Invalid postback or callback argument.
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.
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.
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50712.6; ASP.NET Version:2.0.50712.6
Sorry I should have updated this thread when I found the work around.
RC gave me a better error message which helped me in fixing this.
## Actual Error ##
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.
You can also benefit from those features by leaving it enabled then register your control for event validation. Simply add the following call in the PreRender or Render page life cycle then your control should work without having to turn off eventValidation:
This will not work on PreRender, the error is as such "RegisterForEventValidation can only be called during Render();
"... but there is not OnRender event available. Any suggestions on how to keep the validation on and get around this problem? Again, this problem only occurs in RC1.
Has anyone found a correct way to resolve this issue?
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.
use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
How to do this? As someone said before, it is not possible to do it in PreRender and there is no Render event.
there is Render event in base class. to use it :
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
MyBase.Render(writer)
End Sub
but, the problem is I do not know how to use RegisterForEventValidation method. where is the example for this?
I also don't know what to do.. the mdsn isn't very helpful, too.
But I wanted You, if you can do me a favour.
If You find out how to solve the Problem, couldi you please send me an Email. Cause usually I'm not using english forums.
I promise I'll post the solution if I find it, too.
krathni
Member
35 Points
7 Posts
Invalid postback or callback argument.
Sep 27, 2005 01:15 PM|LINK
I have a composite control which consists of label, linkbutton & textbox control. Depending on the display mode (a property within the control) one of the control gets displayed. However when the linkbutton is clicked it seems to throw up this error. The control works fine in .NET 1.1.
The control inherits from System.Web.UI.WebControls.WebControl, IPostBackDataHandler & INamingContainer & this is my IpostBackDataHandler implementation
#region IPostBackDataHandler Implementation
void IPostBackDataHandler.RaisePostDataChangedEvent()
{
OnTextChanged(System.EventArgs.Empty);
}
bool IPostBackDataHandler.LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
bool retVal = false;
if (!this.Text.Equals(postCollection[postDataKey]))
{
this.Text = postCollection[postDataKey];
retVal = true;
}
return retVal;
}
#endregion IPostBackDataHandler Implementation
#### ERROR BEGIN ####
Invalid postback or callback argument.
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.
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.]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +2088580
System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey, NameValueCollection postCollection) +89
System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +11
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +718
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3817
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50712.6; ASP.NET Version:2.0.50712.6
gerrod
Member
145 Points
29 Posts
Re: Invalid postback or callback argument.
Sep 30, 2005 03:18 PM|LINK
I have some code generating the same exception - only my code used to work in Beta 2 (v2.0.50215), and now doesn't work in RC1 (v2.0.50712).
Can someone from MS please comment on this exception? Is this part of the security changes from Whidbey Beta 2 to RTM, regarding bubbling of events?
gerrod
Member
145 Points
29 Posts
Re: Invalid postback or callback argument.
Sep 30, 2005 03:52 PM|LINK
I found a work-around to my problem. Try adding this into the <system.web> section of your web.config file:
Works for me.
/gerrod
krathni
Member
35 Points
7 Posts
Re: Invalid postback or callback argument.
Sep 30, 2005 05:06 PM|LINK
RC gave me a better error message which helped me in fixing this.
## Actual Error ##
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.
JoeBerg
Participant
880 Points
176 Posts
Microsoft
Re: Invalid postback or callback argument.
Sep 30, 2005 10:03 PM|LINK
Page.ClientScript.RegisterForEventValidation(
this.UniqueID);Hope this helps,
Joe
morda31
Member
5 Points
1 Post
Re: Invalid postback or callback argument.
Oct 24, 2005 10:22 PM|LINK
Thanks
Sincerely,
Oleg
mreyeros
Contributor
4022 Points
736 Posts
Re: Invalid postback or callback argument.
Nov 01, 2005 01:12 PM|LINK
Aphelion
Member
5 Points
5 Posts
Re: Invalid postback or callback argument.
Nov 05, 2005 07:55 AM|LINK
How to do this? As someone said before, it is not possible to do it in PreRender and there is no Render event.
zhouyuheng
Member
16 Points
7 Posts
Re: Invalid postback or callback argument.
Nov 06, 2005 09:54 PM|LINK
there is Render event in base class. to use it :
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
MyBase.Render(writer)
End Sub
but, the problem is I do not know how to use RegisterForEventValidation method. where is the example for this?
Entity
Member
16 Points
7 Posts
Re: Invalid postback or callback argument.
Nov 14, 2005 05:53 PM|LINK
I also don't know what to do.. the mdsn isn't very helpful, too.
But I wanted You, if you can do me a favour.
If You find out how to solve the Problem, couldi you please send me an Email. Cause usually I'm not using english forums.
I promise I'll post the solution if I find it, too.
thank you very much!
regards Tuldi@gmx.net
Patrick