Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am getting this error while using Dropdown binding with Json am using EnableEventValidation="true" and i also check with scriptmanager stiil am getting same error as follows

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.

This is my aspx code
ASP.NET
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Dropdown with JSON.aspx.cs"  Inherits="Dropdown_with_JSON" EnableEventValidation="true"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.8.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "Jquery.asmx/BindDropdown",
                data: "{}",
                dataType: "json",
                success: function (data) {
                    $("#DropDownList1").append($("<option></option>").val("").html("srre"));
                    $.each(data.d, function (key, value) {
                        $("#DropDownList1").append('<option value="' + value.CategoryID+ '">' + value.CategoryName + '</option>');
                    });
                },
                error: function (result) {
                    alert("Error");
                }
            });
       
    });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <br />
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ControlToValidate="DropDownList1" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
        <br />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
       
    </div>
    </form>
</body>
</html>
Posted
v2
Comments
Can't you set Page EnableEventValidation to false and try once ?
Traybabu 8-Nov-12 6:19am    
if I put EnableEventValidation=false my button clcik event not firing.........
Ravi Tuvar 16-Nov-12 7:12am    
have you tried to debug this in Firebug..is is going into success code? or getting any error?

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