473,508 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Invalid postback or callback argument"

52 New Member
Hi guys,

I want to have a button which opens up a new window when pressed.


Expand|Select|Wrap|Line Numbers
  1. <asp:Button ID="Button1" runat="server" Text="Open new window" />
  2.  
  3. ...
  4.  
  5. Button1.Attributes.Add("OnClick",
  6.                 "window.open(' ... ', null, ' ... ');return false;");
  7.  
But when the button's being clicked on for the first time, nothing would happen. If you click on it again it displays the below 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.

[FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif] 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(St ring uniqueId, String argument) +8620921
System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +72
System.Web.UI.WebControls.TextBox.LoadPostData(Str ing postDataKey, NameValueCollection postCollection) +34
System.Web.UI.WebControls.TextBox.System.Web.UI.IP ostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +14
System.Web.UI.Page.ProcessPostData(NameValueCollec tion postData, Boolean fBeforeLoad) +346
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743
[/FONT]




On the other hand if I use a link instead of a button, it would work fine:

Expand|Select|Wrap|Line Numbers
  1. <a href="..." target="_blank" title="Upload" onclick="window.open(this.href, null, ' ... '); return false;">Open new window</a>
I think this might have something to do with the fact that this button is placed inside an asp:UpdatePanel (I'm using Ajax:TabContainer).

Setting EnableEventValidation to false might solve this and I don't mind using links instead of buttons; but does anyone know the cause of this?



Thanks a lot :)
Jan 14 '09 #1
9 4532
Frinavale
9,735 Recognized Expert Moderator Expert
Where do you see this error?
In the window that the button was clicked or the new popup window?
Jan 14 '09 #2
200dogz
52 New Member
@Frinavale
In the window that the button was clicked; there's no popup window.
Jan 14 '09 #3
Blacky
40 New Member
hi,

use this code in the page_load event,

if(!IsPostBack)
Button1.Attributes.Add("OnClick", "window.open('Default.aspx', null, ' ... ');return false;");

here the 'Default.aspx' is the page i want to be shown in the popup window.
try it.

thanks in advance
blacky
Jan 15 '09 #4
200dogz
52 New Member
@Blacky
Thanks a lot Blacky; I've found out the problem was due to the url of the new window, which I set to something like:
Expand|Select|Wrap|Line Numbers
  1. Default.aspx?parameter=document.getElementByID('TextBox').value
  2.  
In an attempt to make a search button that pops up a new window.....

Anyway, can you point out what I need to do to achieve this?

Many thanks
Jan 15 '09 #5
200dogz
52 New Member
I've googled and found a way to do it using Response.Write().

However it would throw a Sys.WebForms.PageRequestManagerParserErrorExceptio n if I do that. After more googling this seems to be caused by a bug in Ajax, which happens when you have Response.Write inside an UpdatePanel, and it doesn't look like it can be overcome easily.

If anyone knows another way, please help =(

Cheers
Jan 15 '09 #6
Frinavale
9,735 Recognized Expert Moderator Expert
Response.Write is not the best way to solve this problem.
When you use it, whatever you add to the Response.Write could appear anywhere in your HTML. For example it could place your output above the <head> section.

This doesn't go over too well with Ajax since only the portion of the page that caused the postback should be updated.

JavaScript is sometimes messed up by Ajax as well...especially after a partial page update. To get around this you should move your code that opens the new window into a JavaScript function and register it with the ScriptManager. You need to indicate that this script has to be loaded every time an asynchronous postback occurs so that it will still work after a partial page update happens. I forget which method does this so you'll have to look into which one will do this for you.
Jan 15 '09 #7
Curtis Rutland
3,256 Recognized Expert Specialist
Response.Write if used in your codebehind, as far as I know, will almost always result in writing the content before any HTML tags, since the processing happens before the page is sent back to the client.

The only time Response.Write is really good is if you are using inline code.
Jan 15 '09 #8
200dogz
52 New Member
I don't quite understand how to use ScriptManager.

When do I need to register the script with ScriptManager.RegisterClientScriptBlock, when do I call the registered script, and how do I send parameters in?
Jan 15 '09 #9
Frinavale
9,735 Recognized Expert Moderator Expert
Here are so more details on how to use the ScriptManager. I think you'll be most interested in how to use the RegisterClientScriptInclude method.
Jan 16 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3843
by: Ron | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
2
3177
by: Vinod I | last post by:
Hi Team, When I tryed following code, I am getting the Runtime Error as "The View State is invalid for this page and might be corrupted." Exception Details: System.Web.HttpException: The View...
0
1931
by: dbuchanan | last post by:
Hello, Why am I getting this error? I don't know how to isolate it. It occurs intermittently. Has anyone seen this before? Here is the full text \\ System.IO.FileLoadException was...
4
19743
by: Amil | last post by:
I've upgraded to VS 2005. I have a page that contains no submit buttons...it merely shows some data. But, several times a day (out of thousands of hits), I get this error: ...
3
7392
by: Martin | last post by:
Hi, I have an aspx page with two dropdownlist controls. I update the options in the second ddl based on selection made in the first. I do this with the ICallbackEventHandler interface, as per...
1
2702
by: DCC700 | last post by:
After upgrading a web application from VS 2003 to 2005 there is a page where any control event that should cause a postback instead generates an Invalid character error on the page. For example a...
1
7998
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL:...
4
3370
by: robert | last post by:
On a server the binary (red hat) installed python2.4 and also a fresh compiled python2.5 spits "sem_post: Invalid argument". What is this and how can this solved? Robert ============== ...
1
2792
by: eBob.com | last post by:
I have some code which is trying to determine where text will wrap in a custom text box (which Inherits from Control). It determines the number of characters which will fit in the first line, but...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.