Invalid postback or callback argument

Asked

Viewed 3,294 times

4

I’m having a mistake that came to nothing, I’m two days trying a solution to the same and so far unsuccessful.

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

inserir a descrição da imagem aqui

<%@Page Title="" 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>

is my codebehind has only pageload changes

  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", "");
            }

    }
  • I had this problem too. In my case it was because there were two "Forms" on my masterpage. I was using a template and I forgot to remove "Form" from the template. I removed and solved my problem.

  • I believe they already have, but this happens to me when there is a form tag on a page that uses a master page.

1 answer

2

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

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

<%@ Page EnableEventValidation="false" %>

Put 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 that may cause this problem, for example if there are two tags <form> nestled 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.

  • In my case were nested Forms. Thanks @Loudenvier!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.