Saturday, March 24, 2012

Dependent Dropdown + AJAX Error

Hello Friends

I have gone mad with this problem.

For this i am unable to continue with my project........

So plz help me.........

I have input form where........

I have two drop down in a .aspx page .

When I change the first dropdown the secound dropdown takes its vales form the database and poputate it using ajax.

All this is happening cool.......

But when i try to save the values to the data base it shows the following error......

Server Error in '/Equill_Web_v2' Application.

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@dotnet.itags.org. 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 <%@dotnet.itags.org. 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 <%@dotnet.itags.org. 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) +2127900
System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +106
System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection) +55
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +11
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +408
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3776



Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

I have tried this also

ddlParentLocation.Attributes.Add("onchnage", Page.ClientScript.GetPostBackEventReference(ddlParentLocation, "Select$" + ddlParentLocation.SelectedIndex.ToString, True))

But this of no use to me till now.........

Please help........

Well, for some reason, what you did is considered an invalid postback.

You can solve this problem in three ways:

1. In your web.config file, under system.web insert the following:
<pages enableEventValidation="false"/>

2. Get the data only to the client and add the items in javascript to your dropdown lists

3. Do the same using CascadingDropdownList from AjaxToolkit, this would save a whole bench of javascript to implement solution 2.



Thanks Vinija

The option 1 and 2 is not working but i am considering the third option.

But I am not really getting how to implement it.

Still i m reading few articles to get it done.Yes

Thanks

Amit Yes


I first try to add

<%@. Page ... EnableEventValidation="false" %>

the specific page which show the error, not to the web.config. This always works for me when I change a server side dropdownlist collection in the client side by javascript.


Vinija:

Do the same using CascadingDropdownList from AjaxToolkit, this would save a whole bench of javascript to implement solution 2.

Won't work, CascadingDropdownList also needs enableeventvalidation=false


Hi dev,

If you are facing this problem so please write EnableEventValidation="true" in the line

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" EnableEventValidation="false"%>

It will help you.

Thanks

Swapnil

"If it is working so please "mark as answer""


swapnil.malviya:

If you are facing this problem so please write EnableEventValidation="true" in the line

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" EnableEventValidation="true"%>

It will help you.

You mean EnableEventValidation="false" right?


Yes.

No comments:

Post a Comment