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
<%@ 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.
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...
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.
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">

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
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...
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •