Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

When I click on the link in the gridview,I am getting this below error. please anybody can help me.

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

and my page goes like this
VB
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PatientMapByFacility.aspx.cs" EnableEventValidation="false"
    MasterPageFile="~/Master_Pages/PhysicianMaster.Master" Inherits="CarePortalOnline.CareHIEUI.PatientMapByFacility" %>


When I set
C#
EnableEventValidation="false"
OnClick="lnkView_Click" event is not firing.
Posted
Updated 16-May-12 11:50am
v6
Comments
Code 89 16-May-12 6:04am    
can you post your error
Ganga Patangi 16-May-12 6:10am    
Previously I was getting below error.

Invalid postback or callback argument. Event validation is enabled using 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

When i set EnableEventValidation="false" nothing is happening. I mean no click event is firing...

VB
Dim btn As LinkButton = CType(sender, LinkButton)
       Dim g As GridViewRow = CType(btn.NamingContainer, GridViewRow)
       Dim rowindex As Int16 = g.RowIndex
       Dim hid As HiddenField
       hid = gvPatient.Rows(rowindex).Cells(0).FindControl("hidid")

       Dim lnkbtn As LinkButton
       lnkbtn = gvPatient.Rows(rowindex).Cells(3).FindControl("LinkButton1")
              
       GetAllPatientList()



try using this...onclick event of linkbutton in a gridview..I had already used this code and working fine..Change it in C# and use.
 
Share this answer
 
Comments
Ganga Patangi 17-May-12 2:50am    
Thanks for ur post...

I have tried this one and its working fine in local system. but it is not working when it is deployed in server

protected void lnkView_Click(object sender, EventArgs e)
{
Session["ControlId"] = null;
Session["PatientName"] = null;
GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
Label lblId = (Label)gvRow.FindControl("lblId");
Label lblName = (Label)gvRow.FindControl("lblFirstname");
Label lblLastName = (Label)gvRow.FindControl("lblLastName");
Label facId = (Label)gvRow.FindControl("facId");
string PatientName = lblName.Text + " " + lblLastName.Text;
Session["PatientName"] = PatientName;
GetMappingpatientListByFacility(Convert.ToInt32(lblId.Text.Trim()),Convert.ToInt32(facId.Text.Trim()));
GetMappedpatientList(Convert.ToInt32(lblId.Text.Trim()));
Session["ControlId"] = lblId.Text.Trim();
Session["FacilityId"] = facId.Text.Trim();

}

ERR0R:(After deploying)

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customerrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customerrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customerrors mode="Off">



Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customerrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customerrors mode="RemoteOnly" defaultredirect="mycustompage.htm">

Ganga Patangi 22-May-12 5:31am    
Hey Ashish thanks... I got solution ....
AshishChaudha 23-May-12 4:31am    
Hi ganga, atleast rate if you got the solution...thanks
Set
C#
<customerrors mode="Off" />
in web.config file
 
Share this answer
 
Comments
Ganga Patangi 17-May-12 4:39am    
Thanku i got to know the exact error...
AshishChaudha 17-May-12 4:54am    
no ratings ganga???
Code 89 17-May-12 5:09am    
my 5!
1) First Check whether you write some HTML tags inside the Textbox that you are going to store it on DB.

Sol: set the EnableEventValidation="False" either place this on page Directive or put this on web.config file

2) Check whether you are going to bind the data to Gridview , dropdownlist or any server control you should place the binded code within the IsPostBack -- property on Page_Load
 
Share this answer
 
v4
Comments
Ganga Patangi 16-May-12 5:54am    
Hi,

Already i have placed the code behind binding in page_load method. and set EnableEventValidation=false on page directive.

here my code goes....

Collapse | Copy Code

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetAllPatientList();
}
}



protected void GetAllPatientList()
{
if (Session["FacilityID"] != null)
{
int facilityId = Convert.ToInt32(Session["FacilityID"]);
CareHIEBL objCareHIEBL = new CareHIEBL();
List objPatientDetailsBOList = objCareHIEBL.GetAllPatientsByFacility(facilityId);
grdPatientList.DataSource = objPatientDetailsBOList;
grdPatientList.DataBind();
}
}

click event is not firing...
priyanshbhaliya 16-Oct-13 14:26pm    
http://www.softcodearticle.com/2012/11/asp-net-gridview-invalid-postback-or-callback-argument-error/



here is ur solution....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900