4

Estou tendo um erro que do nada veio a acontecer, estou a dois dias tentando uma solução para o mesmo e até agora sem sucesso.

Possuo um form todo feito em webforms que ao clicar no button para enviar os dados é gerado o seguinte erro.

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>

é meu codebehind só tem alterações no 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", "");
            }

    }
2
  • Tive esse problema também. No meu caso foi pelo fato de haver dois "Forms" na minha masterpage. Estava usando um template e acabei esquecendo de remover o "Form" do template. Removi e resolveu o meu problema. 15/02/2017 às 12:39
  • Acredito que já arrumaram, mas isso ocorre para mim quando há uma tag form em uma pagina que utiliza uma master page. Caso tenha troca por uma div
    – Henrique
    26/08/2018 às 22:11

1 Resposta 1

2

Isso acontece porque você está provavelmente modificando controles de servidor (com runat="server") no cliente dinamicamente, ou está enviando o form mas não do botão "esperado" pelo ASP.NET, ou seja, não de um script que tenha sido registrado para validação.

Você pode desabilitar validação de eventos nessa página, mas isso diminui a segurança do seu site:

<%@ Page EnableEventValidation="false" %>

Coloque como a primeira linha do seu formulário, sob seu próprio risco.

Se souber inglês, não deixe de ler: Why do I get "Invalid postback or callback argument" Errors?

Há outros motivos que possam gerar esse problema, por exemplo, se houver duas tags <form> aninhadas no mesmo ASPX.

Contudo minha sugestão seria migrar para ASP.NET MVC e evitar toda a dor de ter que brigar contra o ASP.NET para implementar programação avançada no cliente.

1
  • No meu caso eram forms aninhados. Obrigado @Loudenvier!
    – Jacobson
    9/04/2019 às 12:40

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .