473,883 Members | 1,796 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 enableEventVali dation="true"/> in configuration or <%@ Page EnableEventVali dation="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 ClientScriptMan ager.RegisterFo rEventValidatio n 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.Argument Exception: Invalid postback or callback argument. Event validation is enabled using <pages enableEventVali dation="true"/> in configuration or <%@ Page EnableEventVali dation="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 ClientScriptMan ager.RegisterFo rEventValidatio n 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:

[ArgumentExcepti on: Invalid postback or callback argument. Event validation is enabled using <pages enableEventVali dation="true"/> in configuration or <%@ Page EnableEventVali dation="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 ClientScriptMan ager.RegisterFo rEventValidatio n method in order to register the postback or callback data for validation.]
System.Web.UI.C lientScriptMana ger.ValidateEve nt(String uniqueId, String argument) +8620921
System.Web.UI.C ontrol.Validate Event(String uniqueID, String eventArgument) +72
System.Web.UI.W ebControls.Text Box.LoadPostDat a(String postDataKey, NameValueCollec tion postCollection) +34
System.Web.UI.W ebControls.Text Box.System.Web. UI.IPostBackDat aHandler.LoadPo stData(String postDataKey, NameValueCollec tion postCollection) +14
System.Web.UI.P age.ProcessPost Data(NameValueC ollection postData, Boolean fBeforeLoad) +346
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +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:TabContain er).

Setting EnableEventVali dation 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 4569
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.Attribu tes.Add("OnClic k", "window.ope n('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.Pa geRequestManage rParserErrorExc eption 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...especial ly 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.R egisterClientSc riptBlock, 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 RegisterClientS criptInclude method.
Jan 16 '09 #10

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

Similar topics

1
3900
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 get the following error: Invalid file name for monitoring: 'E:\'. File names for monitoring must have absolute paths, and no wildcards. Description: An unhandled exception occurred during the
2
3225
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 State is invalid for this page and might be corrupted. Stack Trace: System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +150 System.Web.UI.Page.LoadPageViewState() +16
0
1953
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 unhandled
4
19767
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: System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page...
3
7430
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 "Implementing Client Callbacks Without Postbacks in ASP.NET Web Pages" (http://msdn2.microsoft.com/en-us/library/ms178208.aspx) This works.
1
2732
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 drop down list is set to AutoPostBack, and for OnSelectedIndexChanged should update the values of other drop down lists. This page works fine in VS 2003, and the other pages with similar controls are posting back fine in 2005. Has anyone else...
1
8041
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: http://(address.of.my.webcam):port/LiveView.html and
4
3387
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 ============== server # python2.4 sem_post: Invalid argument
1
2818
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 then encounters an exception when it calls MeasureCharacterRanges to see if the next character, i.e. the one destined to become the first character of the second line, will fit. The message says only "Invalid parameter" - it does not say which...
0
9942
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9792
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10847
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10416
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9574
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4220
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3233
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.