Invalid postback or callback argument

3

I'm having a mistake that started to happen, I've been trying for a couple of days for a solution to it and so far without success.

I have a whole form made in webforms that when clicking the button to send the data the following error is generated.

<%@PageTitle="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Delivery_automatic.aspx.cs" Inherits="UI.Delivery_automatic" EnableEventValidation="true"  %>

<!doctype html>
<%--<html xmlns="http://www.w3.org/1999/xhtml">--%>
<%--ANGULAR JS--%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>DELIVERY_AUTOMATIC</title>

    <%--Colocar esse script em um arquivo único --%>
    <%--somente numeros--%>
    <script type="text/javascript">
        var specialKeys = new Array();
        specialKeys.push(8); //Backspace
        function IsNumeric(e) {
            var keyCode = e.which ? e.which : e.keyCode
            var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
            document.getElementById("error").style.display = ret ? "none" : "inline";
            return ret;
        }



        //usando datepicker no textbox
        <%--            $(function () {
            $("#<%= data.ClientID %>").datepicker();
        });--%>



    </script>


</head>




<body>
    <div class="container">
        <div style="text-align: center;">
            <div class="well well-sm">
                <asp:Label ID="TITULO" runat="server" Text="ENTREGA AUTOMÁTICA" Font-Bold="true" ForeColor="Red"></asp:Label>
            </div>
        </div>
    </div>

    <div class="col-md-1">
    </div>


    <div class="panel panel-primary col-md-3">



        <form runat="server" visible="true">


            <table class="table table-reflow">
                <tbody>

                    <tr>
                        <th scope="row"></th>
                        <td>

                            <span class="label label-default">Cliente:</span>                            
                            <asp:DropDownList ID="DropLabs" runat="server" DataSourceID="DataLabs" DataTextField="LAB" DataValueField="COD_LAB"  AppendDataBoundItems="True" Width="155px" AutoPostBack="true">
                                <asp:ListItem Value="0" Selected="True">---</asp:ListItem>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="DataLabs" runat="server" ConnectionString="Data Source=S-CUPBR04;Initial Catalog=DMD_Portal;Persist Security Info=True;User ID=dmddeveloper;Password=dmddeveloper" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [COD_LAB], [LAB] FROM [LABS]"></asp:SqlDataSource>

                        </td>

                    </tr>

                    <tr>
                        <th scope="row"></th>
                        <td>
                            <span class="label label-default">Código Cliente:</span>                     

                            <asp:TextBox ID="codcli" runat="server" Enabled="false" Width="150px"></asp:TextBox>
                        </td>
                    </tr>

                    <tr>
                        <th scope="row"></th>
                        <td>
                            <span class="label label-default">Nome entrega:</span>



                            <asp:DropDownList ID="DropJobname" runat="server" DataSourceID="DataEntrega" DataTextField="JOBNAME" DataValueField="JOBNAME" Width="120px">
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="DataEntrega" runat="server" ConnectionString="<%$ ConnectionStrings:DMD_DEPLOYConnectionString %>" SelectCommand="SELECT JOBNAME FROM SysHive.dbo.AUTODOWN_JOBLIST"></asp:SqlDataSource>
                        </td>
                    </tr>

                    <tr>
                        <th scope="row"></th>
                        <td>
                            <span class="label label-default">Periodicidade:</span>
                            <asp:DropDownList ID="DropPeriodic" runat="server" Width="150px">
                                <asp:ListItem Value="D">Diário</asp:ListItem>
                                <asp:ListItem Value="W">Semanal </asp:ListItem>
                                <asp:ListItem Value="M">Mensal </asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>

                    <tr>
                        <th scope="row"></th>
                        <td>
                            <span class="label label-default">Data:</span>
                            <input type="text" id="datepicker" name="inputdate" required=""/>
                        </td>
                    </tr>

                    <tr>
                        <th scope="row"></th>
                        <td>
                            <span class="label label-default">Email Cliente:</span>
                            <asp:TextBox ID="email" runat="server" Width="150px"></asp:TextBox>
                        </td>
                    </tr>

                    <tr>
                        <th scope="row"></th>
                        <td>
                            <span class="label label-default">Pasta Download:</span>
                            <asp:FileUpload ID="FileDown" runat="server" />


                        </td>
                    </tr>

                    <tr>
                        <th scope="row"></th>
                        <td>
                            <span class="label label-default">Pasta Destino:</span>
                            <asp:FileUpload ID="FileDesti" runat="server" />
                        </td>
                    </tr>


                    <tr>
                        <th scope="row"></th>
                        <td>
                            <a data-toggle="modal" href="#ModalConfirm" class="btn-primary btn-block">SOLICITAR ENTREGA</a>
                        </td>
                    </tr>



                </tbody>
            </table>

        </form>







        <div id="ModalConfirm" class="modal fade in">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                    </div>
                    <div class="modal-body">
                        <p>Solicitar  entrega automática?</p>
                    </div>
                    <div class="modal-footer">
                        <div class="btn-group">
                            <button class="btn-danger btn-xs" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>Não</button>
                            <button type="submit" id="btn1" class="btn-primary btn-group-lg" onserverclick="btn_Delivery" runat="server"><span class="glyphicon glyphicon-check"></span>Sim</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <p></p>
        <%--<a data-toggle="modal" href="#ModalConfirm" class="btn-primary btn-group-sm">SOLICITAR ENTREGA</a>--%>
    </div>








    <div class="col-md-5">
    </div>
</body>
</html>
</asp:Content>

my codebehind only has changes in pageload

  protected void Page_Load(object sender, EventArgs e)
    {
        //Obtendo cod cliente automatico           
            if (DropLabs.SelectedItem.Text.ToString() == "---")
            {
                codcli.Text = "";
            }
            else
            {
                codcli.Text = DropLabs.SelectedValue.ToString();//.Replace("0", "");
            }

    }
    
asked by anonymous 13.10.2016 / 15:20

1 answer

0

This happens because you are probably modifying server controls (with runat="server") on the client dynamically, or you are sending the form but not the "expected" button by ASP.NET, that is, not a script that has been registered for validation.

You can disable event validation on this page, but this reduces the security of your site:

<%@ Page EnableEventValidation="false" %>

Place as the first line of your form, at your own risk.

If you know English, be sure to read: Why do I get" Invalid postback or callback argument "Errors?

There are other reasons for this problem, for example, if there are two <form> tags nested in the same ASPX.

However my suggestion would be to migrate to ASP.NET MVC and avoid all the pain of having to fight against ASP.NET to implement advanced client programming.

    
15.10.2016 / 04:37