.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to CATCH "Invalid postback or callback argument" exception?

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net


How can I catch this exception? I do not want it to stop my page execution. Can/Should I do that?

Server Error in '/' 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

View Complete Post

More Related Resource Links

SQL Server 2005 Try and Catch Exception Handling

I'm pretty excited to see that there is some real error handling for T-SQL code in SQL Server 2005. It's pretty painful to have your wonderfully architected .NET solution tainted by less-than-VBScript error handling for stored procedures in the database. The big difference being the addition of TRY..CATCH blocks. Let's take a look:

reader.getordinal("column_may_not_exist") how to catch the exception?



would any body please help me to catch the exception if the column doesnot exist as my table columns are not static.

sometimes its throwing me indexoutofrange exception as the column doesnot exist

thanks for the help guys

Unable to catch WCF EndpointNotFound exception in SecurityToken.GetToken( . )

I have a set of WCF services that I am integrating with, I can not change them in any way because they are provided by a third party. I use a username/password scheme to authenticate with the services. If the services are not available I get an exception (EndPointNotFoundException) from the SecurityTokenProvider class that I can not catch. I understand why the exception is being thrown, I just need to know how I can handle it so that I can gracefully handle the errors in the user interface. Is there a way I can catch this exception or a better way to handle this scenario? The Exception The exception is thrown from System.IdentityModel.Selectors.SecurityTokenProvider : GetToken( TimeSpan timeout ) public SecurityToken GetToken(TimeSpan timeout) {    SecurityToken token = this.GetTokenCore(timeout);     if (token == null)    {        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.TokenProviderUnableToGetToken, this)));    }     return token;} The channel open part When I open the channel I have it wrapped in exception handling, but none of it seems to trap the SecurityToken exception. I am using the ExceptionHandlingProxyWrapperBase try{    this.Open();} catch( EndpointNotFoundException epnfe ){    // Handle the exception} catch( E

No return from unmanaged code, methods to catch exception?


I am developing a c# application that needs to calls functions from a c header file. I use

[System.Runtime.InteropServices.DllImport("xxx.dll", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true,SetLastError=true)]
        public static extern Byte xxxx(IntPtr hResourceContext, ushort xxxx, ref structa aaa,ref Result_struct Result, Byte b);

to import the dll method. When I call this method in C#, the application simply exits without throwing an exception or error. I've used similar approach for other methods from the same dll which involves passing nested structs as parameter and they work fine. I would like to know how I can debug the code/ catch errors/exceptions from the unmanaged code.

I tried to include the SetLastError=true during DllImport but it does not help.


Empty Catch in Global.asax to prevent exception from stopping a web application?



I'm using a static Timer in my Global.asax to run a method at regular intervals. When the method throws an exception, my application is stopped. I have used an empty catch to prevent exceptions from stopping the application something like below code. Is there a disadvantage to use such an approach?


 protected void Application_Start(object sender, EventArgs e)

 public class TimerStarter
            private static System.Threading.Timer threadingTimer;

            public static void StartTimer()
                if (null == threadingTimer)
                    threadingTimer = new System.Threading.Timer(new System.Threading.TimerCallback(CheckData),HttpContext.Current, 0, 50000);

            private static void CheckData(object sender)
                   // a method that reading xml file from another url              
                    // empty catch to prevent stopping the application




Getting Exception info from catch block to Application_Error event of HttpModule


I need some help regarding one issue I am facing. I created a httpmodule for hadling the unhandled errors and I need to log those errors using log 4 net in database.

Everting working fine but I am not getting any error information once the error was hadled and I need that info too. I want to make it as a centralize module which can trap all errors and log those errors.

How call application_error event of httpmodule from catch block...so that I can log that info there and I no need log in every catch block..


throw and catch exception handling



iam inserting record in three tables in a database, iam using begin trans , commit transaction and rollback,

i want to use throw method, if  any value insert wrong, pls correct me, i want to throw the error and

its go to rollback

running = false;
                        int updaterec = DBmgr.ExecuteNonQuery(CommandType.Text, "update ASArrivedcontainer set billgen ='Y' where billgen ='y' and acontinerid in ("+SelValues+")");
                        if (updaterec > 0)
                            running = true;
                            DataSet BillContainerDetails = BillingDetails();

WCF REST Catch Exception ClientSide


I am using WcfRestContrib which allows me to throw a WebException from the server (among other things). Very Similar to how the Rest Starter Kit allows with WebProtocolException. This sets the proper return code and a helper string. (this is visible in a browser so I know it does work)

I am using the WebChannelFactory for the client side. What I would like to do is try to catch this message on the client side but am unable to do so. The client receives a ProtocolException with a brief explanation about the error code.

I added a custom Behavior to the client side to add a message inspector but the exception is thrown before the AfterReceiveReply call is made. How can I accomplish what I am looking for?

Please Help! Thanks!

Windows Service crash - catch exception


A windows service written in C# is intermittently crashing on a server. If I want to log the reason for crash, can I add try catch block in OnStop method?

will onStop  method get initiated on crashing?

protected override void OnStop()

SQL Server try-catch inner exception message conundrum



The following SQL statement below is a good example of some SQL that throws an exception with nested details. It seems in the catch part of the statement I can only get outer exception details Could not create constraint. See previous errors (not very useful!). What I want to get is the inner exception message:

Introducing FOREIGN KEY constraint 'FK_TWO' on table 'TABLE2' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints (you can get this message by running the code without try-catch).

In the Catch block, how can this be achieved in T-SQL? If not is this something that can be fixed in SQL going forward, where can I send this request?


      CHAR(50) NOT NULL);




Every self-respected programmer should include exception handling techniques. Sometimes your application will generate an error. Regardless of who was responsible for this error, the programmer or the user, it is up to the first to include the necessary exception handling techniques to keep his/her program from crashing. The .Net environment provides useful techniques for avoiding disastrous errors such as try-catch statements and user-defined exceptions.

Global Exception Handling with ASP.NET

After your global exception handler has done its work, you'll want to redirect the users of your website to a friendly page that tells them that something has gone wrong, and then provide them with customer support information as well as a link back to your web application's home page.

Error while using exception handling block el 4.1


Hi Folks,


i am trying to use tyhe exception handling block of Enterprise library 4.1.


I just createda polisy and used IndexOutOfRangeException and added a replace handler and a logging handler to it.

I am using the NotifyRethrow PostHandlingAction to the exception.


During runtime I am getting an exception on the HandleException event, The exception is added below:



Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 42:             catch (Exception ex)
Line 43:             {
Line 44:                 bool reThrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy");
Line 45:         

userprincipal.changepassword throws exception


Hi all,

      userprincipal.changepassword(oldpassword, newpassword);

gives error: that is Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)

but userDirectoryEntry.invoke("ChangePassword", new object[] { oldpassword, newpassword });

      userDirectoryEntry.CommitChanges works fine.

Any one please tell me the reason behind this.

active directory exception unusual behaviour


i have a small problem
i want user names from active directory for an auto completer type of service
the method is always throwing an exception 
"searcher.FindAll()' threw an exception of type 'System.DirectoryServices.DirectoryServicesCOMException' System.DirectoryServices.SearchResultCollection 

"Exception from HRESULT: 0x800AC472"


Am Exporting Data in to Excel File,meanwhile if i open any other Excel file than the excel File on which am exporting data gets opened up Automatically having name Book1.How should i stop these excel file not to get open.In the Error log i get an error message showing " Exception from HRESULT: 0x800AC472" . Need help on these.Thanks in Advance.

WebControls.TableRow throws exception on Add()


I have the following method to strip hidden and user-specified columns from a gridviewrow and return a tablerow. 

    Private Shared Function StripHiddenColumns(ByVal gvRow As GridViewRow, ByVal ColumnsToExclude() As Integer) As TableRow

        Dim row As New TableRow
        Dim i As Integer = 0
            For Each cell As TableCell In gvRow.Cells
                If cell.Visible Then
                    If Not ColumnsToExclude.Contains(i) Then
                    End If
                End If
                i += 1

            Return row
        Catch ex As Exception
            Throw ex
        End Try
    End Function

However, when I run this code and hit the Add method for the TableRow,  I get an InvalidOperationException stating the Collection was modified; enumeration operation may not execute.  I've gotten this exception before, but usually it's because I'm attempting to modify a table that is databound.  This particular one is not, i am creating it.  Can anyone offer any insight? 

Thanks in advance.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend