0


I am tring to filter an ASP.net DataSet, using parameters from dropdownlist (which field to filter), and a textbox (for the criteria).

Here is the client code:

$("#btnFilter").click(function(){        
    $.ajax({    
            type: "POST",<br/>
            url: "Default.aspx/selectFrom",<br/>
            data: "{field:" + $("#ddl1").val() + ", criteria:" + $("#txt1").val() + "}",<br/>
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {<br/>
                $("#gvHere").html(msg.d);
            },<br/>
            error: function() {                
                alert("Failed to sort table");
            }
        });



(I would love to add also my html page but I cannot because the question itself is an HTML and I can't disable it... )

Anyway, when trying to click the filter button - I get an annoying ASP.net error page with stack trace:

[ArgumentException: Invalid postback or callback argument.  Event validation is enabled using  in configuration or  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) +2132728
   System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +108
   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) +353
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1194

Does anyone knows what am I doing wrong?

Thanks in advance!

Assaf
  • 750
  • 2
  • 9
  • 22
  • The first line pretty much answers your question... either disable event validation for that page or Google "ClientScriptManager.RegisterForEventValidation" and add your ajax event to the manager – Serj Sagan Aug 09 '11 at 11:50
  • After disabling event validation - I just get an empty page instead of running the function "selectFrom" as I wished. Any further help, anyone? – Assaf Aug 09 '11 at 12:11
  • http://stackoverflow.com/questions/228969/invalid-postback-or-callback-argument-event-validation-is-enabled-using-pages - this post could be usefull – Nastya Kholodova Aug 09 '11 at 12:15

0 Answers0