• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 984
  • Last Modified:

Invalid postback or callback argument.

I keep getting the following error after submitting a form on a site I'm trying to maintain.  The app was written for the 1.1 framework.  The error appears after a survey (which appears in a pop up window) is completed on the site. The information submits, but then this error is returned.  I have pasted the code behinds for the page below.

Server Error in '/accessce' 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 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) +173
   System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +72
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +35
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074
private void Page_Load(object sender, System.EventArgs e)
  {
  	this.crypto = new SymmCrypto(SymmCrypto.SymmProvEnum.DES);
 		//Response.Write(decrypt(Request.QueryString["cid"]+""));
 		instance_id = decrypt(Request.QueryString["iid"]+"");
 		course_id = decrypt(Request.QueryString["cid"]+"");	
 		instance_id_encrypted = Request.QueryString["iid"]+"";
 		course_id_encrypted = Request.QueryString["cid"]+"";	
  	if(Request.QueryString["tab"] != null){
	  	int tabIndex = int.Parse(Request.QueryString["tab"]) - 1;
			string tabPage = "tab" + Request.QueryString["tab"];
			
			MultiPage1.SelectPageById(tabPage);
	  	TabStrip1.SelectedTab=TabStrip1.Tabs[tabIndex];
		}
		
    if(!Page.IsPostBack)
    {
    	BindData();
      BindDataList();
      BindExamHistory();
    }
 
  }
 
	protected void clk_disclaimer(object sender, System.EventArgs e){
	  	SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
		 	string mySQL = "Update user_course set disclaimer_read = 1 where UID = " + Context.User.Identity.Name + " and instance_id =" +instance_id;
		 	SqlCommand myCommand = new SqlCommand(mySQL, myConnection);
 
			try{
				 myConnection.Open();
				 myCommand.ExecuteNonQuery();
				 Response.Redirect("view_mycourse.aspx?iid="+instance_id_encrypted+"&cid="+course_id_encrypted);
			}
			
			//catch(System.Exception Exp){
			//		Literal1.InnerHtml = "<font color=#f20000>Error!</font><br>" +  Exp.Message.ToString() + "<br>" + Exp.StackTrace.ToString();
		   //}
			
			finally{
				 myConnection.Close();
			}	
 
 
	}
 
  private string encrypt(string value ){
		return crypto.Encrypting(value, ConfigurationSettings.AppSettings["_mykey"]);
	}    
	private string decrypt(string value ){
		return crypto.Decrypting(value, ConfigurationSettings.AppSettings["_mykey"]);
	}		
 
	protected void refreshData(object sender, System.EventArgs e){
    	BindData();
      BindDataList();
	}
 private void BindData()
  {		
  	//Response.Write(instance_id);
		SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
		SqlCommand myCommand = new SqlCommand("USP_User_View_MyInstance" , myConnection);
		myCommand.CommandType = CommandType.StoredProcedure;
		myCommand.Parameters.Add(new SqlParameter("@instance_id", SqlDbType.VarChar, 100)).Value =  instance_id;	
		myCommand.Parameters.Add(new SqlParameter("@uid", SqlDbType.VarChar, 100)).Value =  Context.User.Identity.Name;	
			
		SqlDataReader myReader = null;
 
			try {
				myConnection.Open();
				myReader = myCommand.ExecuteReader();
			
				
				while (myReader.Read()) 	
			  {
					
					lblNumber.Text = myReader["course_number"].ToString().ToUpper()+"";	
					lblTitle.Text		 = myReader["title"].ToString()+"";
					lblDescription.Text = myReader["Description"].ToString()+"";	
					lblCat.Text = myReader["course_category"].ToString()+"";
					lblType.Text = myReader["course_type"].ToString()+"";
					lblHours.Text = myReader["contract_hours"].ToString()+"";				
					Course_fee.Text = "$"+ myReader["course_fee"].ToString()+"";	
					cert_fee.Text = "$"+myReader["cert_fee"].ToString()+"";	
					myCourse_fee.Text =   myReader["course_fee"].ToString()+"" == "0" ? "--" : myReader["course_paidtext"].ToString()+"";	
					mycert_fee.Text = myReader["cert_paidtext"].ToString()+"";	
					total_fees.Text = "$"+myReader["total_fees"].ToString()+"";	
					lblLocation.Text = (myReader["course_type_id"].ToString()+"" == "2" ?"Online" : myReader["location_and_maplink"].ToString()+""  );	
					lblTime.Text = (myReader["course_type_id"].ToString()+"" == "2" ?"n/a" : myReader["tm_disp"].ToString()+""  );	
					lblStart.Text = (myReader["course_type_id"].ToString()+"" == "2" ?"n/a" : myReader["date_start"].ToString()+""  );
					lblEnd.Text = (myReader["course_type_id"].ToString()+"" == "2" ?"n/a" : myReader["date_end"].ToString()+""  );
					exam_status.InnerHtml = myReader["result_text"].ToString()+"";	
					start_page= myReader["online_start_page"].ToString()+"";	
					txtDisclaimer.Text = myReader["Disclaimer"].ToString()+"";	
	
					if (myReader["disclaimer_exists"].ToString()+"" == "1"){
						spnDisclaimer.InnerHtml = "<br><img src=img/arrows.gif border=0><font color=\"#f20000\"><a href=\"javascript:NewWindow('course_disclaimer.aspx?cid="+course_id + "','',800,600,'yes');\">View Disclaimer</a>";
					}else{
						spnDisclaimer.InnerHtml = "";
					}
					
					if(myReader["disclaimer_required"].ToString() == "1"){
						pnlDisclaimerShow.Visible=true;
						pnlDisclaimerHide.Visible=false;
					}else{
						pnlDisclaimerShow.Visible=false;
						pnlDisclaimerHide.Visible=true;						
					}				
						
					if(myReader["survey_id_num"].ToString() != "" && myReader["survey_id_num"].ToString() != "0" ){
						if(myReader["survey_compl"].ToString()+"" == "1"){
							spnSurvey.InnerHtml = "Survey Completed.";		
						}else{
							spnSurvey.InnerHtml =  "<br><img src=img/arrows.gif border=0><font color=\"#f20000\"><a href=\"javascript:NewWindow('course_survey.aspx?cid="+course_id + "&iid="+instance_id+"&sid="+myReader["survey_id_num"].ToString()+"','',800,600,'yes');\">Take Survey</a>";
						}	
					}else{
						spnSurvey.InnerHtml = "No Survey Available.";
					}				
				
 
 
 
						switch (myReader["result"].ToString()+""){
							case "0":
								cert.Text ="--";						
				    			break;
							case "1":
								//cert.Text ="<font color=\"#f20000\"><a href=\"javascript:NewPrintWindow('certificate.aspx?iid="+encrypt(instance_id)+"&gid="+System.Guid.NewGuid()+"','',700,500,'yes');\">View Certificate</a>";							
								if (myReader["certificate_paid"].ToString()+""=="no"){
									cert.Text ="<a style=\"color:F20000;\" href=\"addToCart.aspx?id=" + encrypt(instance_id) + "&ac=yes&action=addCertToCart\">Enter access Code/Pay</a>";	}
								else{
									if(myReader["survey_req"].ToString()+"" == "1" && myReader["survey_compl"].ToString()+"" != "1"){	
										cert.Text ="<font color=\"#f20000\"><a href=\"javascript:void(0);\" onclick=\"alert('You must complete the course survey before you can view/print you certificate.')\"><img src=img/btn_viewCert.gif border=0></a>";							
									}else{
										cert.Text ="<font color=\"#f20000\"><a href='certificate_new.aspx?iid="+encrypt(instance_id)+"&nm="+encrypt("uid|"+Context.User.Identity.Name)+"&gid="+System.Guid.NewGuid().ToString().Replace("-","")+"' target='frmViewCert'><img src=img/btn_viewCert.gif border=0></a>";							
									}
								}
				    			break;
							case "2":
								cert.Text ="--";						
				    			break;
	
				    		default: 
				    			cert.Text ="--";
				    			break;
				    		}
 
 
 
				if (myReader["active_exam"].ToString()+"" == "0" || myReader["total_questions"].ToString()+"" == "0"){
					spnStartExam.InnerHtml = "No Online Exam";									
				}else{	
					if(myReader["result"].ToString()+"" != "1"){
						spnStartExam.InnerHtml = "<font color=\"#f20000\"><a href=exam_start.aspx?cid="+encrypt(course_id)+"&iid="+encrypt(instance_id)+"&gid="+System.Guid.NewGuid()+"><img src=\"img/btn_startExam.gif\" border=\"0\"></a>";	
					}else{
						spnStartExam.InnerHtml = "n/a"	;
					}
				}
 
				}
		}
		
			catch (System.Exception Exp){
					//literal1.Text = Exp.Message.ToString() + "<br>" + Exp.StackTrace.ToString();
			}
			
			finally { 
				myConnection.Close();
			}
 
				if (lblType.Text == "Online"){
					spnLauncher.Visible= true;
				}
   }
 	protected string evalGrade(string Score){
		if(Score == ""){
			return "--";
		}else{
			return Score;
		}
	}
 
 	protected string PassResult(string passScore){
		if(passScore == "1"){
			return "<font color=#009900 size=3><b>Pass</font>";
		}else{
			if(passScore == "0"){
				return "<font color=#ff0000 size=3><b>Fail</font>";
			}else{
				return "Not Attempted";
			}
		}		
	}
 public string DispPage(string course_fee,string instance_id)
  {		
  		if(Convert.ToDecimal(course_fee)>0){
  			return "<a style=\"color:F20000;\" href=\"addToCart.aspx?id=" + encrypt(instance_id) + "&action=addCourseToCart\">Enter access Code/Pay</a>"; 
  		}else{
  			return "<a style=\"color:F20000;\" href=\"addToCart.aspx?id=" + encrypt(instance_id) + "&action=register\" onClick=\"return confirm('Are you sure you want to register for this course?');\">Free Registration</a>";   		}
	}
 
 private void BindDataList()
  {		
		SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
		SqlCommand myCommand = new SqlCommand("USP_Course_ViewRequiredItems", myConnection);
		myCommand.CommandType = CommandType.StoredProcedure;
		myCommand.Parameters.Add(new SqlParameter("@course_id", SqlDbType.VarChar, 200)).Value = course_id;
 
    SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand); 
		DataSet ds = new DataSet(); 
		myAdapter.Fill(ds); 
		
		listRequiredItems.DataSource = ds;  
		listRequiredItems.DataBind(); 
		if ((ds.Tables[0].Rows.Count)==0){
			
		spnlistRequiredItems.InnerHtml = "0 item(s) found.";
		} 
   }
 
	protected string examLink(string strVal, string tid, string course_status){
		string retval;
		
		switch (strVal){
			case "exam_review":
				retval ="<a href=\"exam_review.aspx?tid="+encrypt(tid)+"&iid="+instance_id_encrypted+"&cid="+course_id_encrypted+"\"><font color=#f20000>View</a>";						
    		break;
 
			case "exam":
				if (course_status == "1"){ //they have already passed a test
						retval ="<a href=\"exam_review.aspx?tid="+encrypt(tid)+"&iid="+instance_id_encrypted+"&cid="+course_id_encrypted+"\"><font color=#f20000>View</a>";						
 	   		}else{
  				retval ="<a href=\"exam.aspx?rev=1&tid="+encrypt(tid)+"&iid="+instance_id_encrypted+"&cid="+course_id_encrypted+"\"><font color=#f20000>Resume</a>";						
 
     		}
    		break;
 
    		default: 
    			retval ="--";
    			break;
    		}		
			return retval;
		}
 	protected string dispGrade(string grade, string isGraded){
		if (isGraded == "no"){
				return "<font color=#000000 >--</font>";			
		}else{
				return "<font color=#000000 >"+grade+"%</font>";	
		}
	}
 	protected string examResult(string passScore, string isGraded){
		if (isGraded == "no"){
				return "<font color=#676767 size=3>--</font>";			
		}else{
			if(passScore == "1"){
				return "<font color=#009900 size=3><b>Pass</font>";
			}else{
				if(passScore == "2"){
					return "<font color=#ff0000 size=3><b>Fail</font>";
				}else{
					return "Incomplete";
				}
			}		
		}
	}
 
 private void BindExamHistory()
  {		
		SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
		SqlCommand myCommand = new SqlCommand("USP_User_ExamHistory", myConnection);
		myCommand.CommandType = CommandType.StoredProcedure;
		myCommand.Parameters.Add(new SqlParameter("@iid", SqlDbType.VarChar, 200)).Value = instance_id;
		myCommand.Parameters.Add(new SqlParameter("@uid", SqlDbType.VarChar, 200)).Value = Context.User.Identity.Name;
 
    SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand); 
		DataSet ds = new DataSet(); 
		myAdapter.Fill(ds); 
		
		listExamHistory.DataSource = ds;  
		listExamHistory.DataBind(); 
		if ((ds.Tables[0].Rows.Count)==0){
			
		spnlistExamHistory.InnerHtml = "0 exams found.";
		} 
  }
 
 
 
	#region Web Form Designer generated code
	override protected void OnInit(EventArgs e)
	{
		//
		// CODEGEN: This call is required by the ASP.NET Web Form Designer.
		//
		InitializeComponent();
		base.OnInit(e);
	}
	
	/// <summary>
	/// Required method for Designer support - do not modify
	/// the contents of this method with the code editor.
	/// </summary>
	private void InitializeComponent()
	{    
		this.Load += new System.EventHandler(this.Page_Load);      
	}
	#endregion
 
}

Open in new window

0
aguawebdesign
Asked:
aguawebdesign
  • 3
1 Solution
 
Anurag ThakurCommented:
You can set this to false on the page or the application but i will not suggest doing that.
<%@ Page EnableEventValidation="true" %>

such an error normally comes when the aspx page is not well formatted means that while compilation no error will be reported but actually the aspx part is not well formed
have a look at the follwoing link - it might be helpful
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_24144158.html
0
 
aguawebdesignAuthor Commented:
Thanks.  By "not well formed" are you referring to a possible error in the html markup?  Or the scripting?
0
 
Anurag ThakurCommented:
yes thats what i meant....
0
 
Anurag ThakurCommented:
I gave up the solution
Usually this error comes only when the aspx page is not well formed
something is added in the aspx side which breaks some kind of control hierarchy
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now