IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

[ASP.NET/C#] Argument de publication ou de rappel non valide


Sujet :

ASP.NET

  1. #1
    Membre du Club
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2005
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2005
    Messages : 65
    Points : 52
    Points
    52
    Par défaut [ASP.NET/C#] Argument de publication ou de rappel non valide
    Bonjour à tous,

    N'hésitez pas à déplacer ce message si il n'est pas à sa place.

    Après m'être arraché les cheveux pendant une demi-journée à trouver l'erreur (je suis débutant), je préfère poster ici en espérant avoir une réponse.

    Ca marche sous Firefox, mais pas sous IE, j'obtiens cette erreur:
    Argument de publication ou de rappel non valide. La validation d'événement est activée via <pages enableEventValidation="true"/> dans la configuration ou via <%@ Page EnableEventValidation="true" %> dans une page. Pour des raisons de sécurité, cette fonctionnalité vérifie si les arguments des événements de publication ou de rappel proviennent du contrôle serveur qui les a rendus à l'origine. Si les données sont valides et attendues, utilisez la méthode ClientScriptManager.RegisterForEventValidation afin d'inscrire les données de publication ou de rappel pour la validation.
    Voici mon code returnform2.aspx:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    <%@ Page Title="" Language="C#" MasterPageFile="~/Front_Style.master" AutoEventWireup="true"
        CodeFile="ReturnForm2.aspx.cs" Inherits="ReturnForm2" EnableEventValidation="true" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="uxPlaceHolder" runat="Server">
        <div class="MainDivLarge">
            <h1>
                Formulaire de retour</h1>
            <form id="Form1" name ="Form1" method="post" action="">
            <table id="Tab1" border="0" cellpadding="0" cellspacing="0" width="100%" style="border-left-color: fuchsia;
                border-bottom-color: fuchsia; border-top-style: none; border-top-color: fuchsia;
                border-right-style: none; border-left-style: none; border-right-color: fuchsia;
                border-bottom-style: none;">
                <tr>
                    <td align="center">
                        <h3>
                            Mode de retour :
                        </h3>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddpReturnType" runat="server" OnLoad="ComboBoxReturnTypeLoad"
                            OnSelectedIndexChanged="ddpReturnType_SelectedIndexChanged">
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>
            <asp:Repeater ID="RPT_Products" runat="server">
                <HeaderTemplate>
                    <table id="Tab2" border="0" cellpadding="0" cellspacing="0" width="100%" style="border-left-color: fuchsia;
                        border-bottom-color: fuchsia; border-top-style: none; border-top-color: fuchsia;
                        border-right-style: none; border-left-style: none; border-right-color: fuchsia;
                        border-bottom-style: none;">
                        <tr style="height: 20px;" class="GridHeadStyle">
                            <th valign="middle" align="center" style="width: 100px;">
                                Type Carte
                            </th>
                            <th valign="middle" align="center" style="width: 100px;">
                                Gencode
                            </th>
                            <th valign="middle" align="center" style="width: 100px;">
                                Produit
                            </th>
                            <th valign="middle" align="center" style="width: 50px;">
                                Quantité
                            </th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr style="height: 20px;" class="GridAlternatingRowStyle">
                        <td valign="middle" align="center" style="width: 100px;">
                            <asp:Label ID="lProductKind" Text='<%# Eval("ProductType") %>' runat="server">
                            </asp:Label>
                        </td>
                        <td valign="middle" align="center" style="width: 100px;">
                            <asp:Label ID="lGencode" Text='<%# Eval("GC_gencode") %>' runat="server">
                            </asp:Label>
                        </td>
                        <td valign="middle" align="center" style="width: 100px;">
                            <asp:Label ID="lProduct" Text='<%# Eval("ProductName") %>' runat="server">
                            </asp:Label>
                        </td>
                        <td valign="middle" align="center" style="width: 100px;">
                            <asp:TextBox ID="tbQte" Text="0" runat="server" Width="50px" MaxLength="4" BackColor="#dcdcdc"
                                OnTextChanged="ChangeTotal" AutoPostBack="true" />
                            <asp:RegularExpressionValidator runat="server" ID="rexQte" ControlToValidate="tbQte"
                                ValidationExpression="\d+" ErrorMessage=" !!!" />
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
                <AlternatingItemTemplate>
                    <tr style="height: 20px;" class="GridRowStyle">
                        <td valign="middle" align="center" style="width: 100px;">
                            <asp:Label ID="lProductKind" Text='<%# Eval("ProductType") %>' runat="server">
                            </asp:Label>
                        </td>
                        <td valign="middle" align="center" style="width: 100px;">
                            <asp:Label ID="lGencode" Text='<%# Eval("GC_gencode") %>' runat="server">
                            </asp:Label>
                        </td>
                        <td valign="middle" align="center" style="width: 100px;">
                            <asp:Label ID="lProduct" Text='<%# Eval("ProductName") %>' runat="server">
                            </asp:Label>
                        </td>
                        <td valign="middle" align="center" style="width: 100px;">
                            <asp:TextBox ID="tbQte" Text="0" runat="server" Width="50px" MaxLength="4" BackColor="White"
                                OnTextChanged="ChangeTotal" AutoPostBack="true" />
                            <asp:RegularExpressionValidator runat="server" ID="rexQte" ControlToValidate="tbQte"
                                ValidationExpression="\d+" ErrorMessage=" !!!" />
                        </td>
                    </tr>
                </AlternatingItemTemplate>
            </asp:Repeater>
            <table id="Tab3" border="0" cellpadding="0" cellspacing="0" width="100%" style="border-left-color: fuchsia;
                border-bottom-color: fuchsia; border-top-style: none; border-top-color: fuchsia;
                border-right-style: none; border-left-style: none; border-right-color: fuchsia;
                border-bottom-style: none;">
                <tr>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <h5>
                            Nb Total Cartes :</h5>
                    </td>
                    <td>
                        <asp:Label ID="lTotal" runat="server" Text="0" />
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <h3>
                            Raison :
                        </h3>
                    </td>
                    <td valign="middle" align="center" style="width: 100px;" colspan="4">
                        <asp:TextBox ID="tbReason" runat="server" TextMode="MultiLine" MaxLength="100" Width="90%" />
                        <br />
                        <asp:RegularExpressionValidator runat="server" ID="rexReason" ControlToValidate="tbReason"
                            ValidationExpression="^[^\0]{0,200}$" ErrorMessage="Max 200 chars" />
                    </td>
                </tr>
            </table>
            <br />
            <asp:Button ID="BtnConfirm" Text="Envoyer" runat="server" OnClick="ConfirmFrom" />
            <br />
            </form>
        </div>
    </asp:Content>
    Voici mon code returnform2.aspx.cs:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using Vevo.DataAccessLib;
    using System.Collections;
     
    public partial class ReturnForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {   
            if (!Page.IsPostBack)
            {
                string exec = "exec GC_WEB_Get_ProductList";
     
                DataTable dtTest;
                dtTest = DataAccess.ExecuteSelect(exec);
                RPT_Products.DataSource = dtTest;
                RPT_Products.DataBind();
            }
        }
     
        protected void ComboBoxReturnTypeLoad(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string exec = "exec GC_WEB_Get_ReturnType";
                DataTable dtTest;
     
                dtTest = DataAccess.ExecuteSelect(exec);
                ddpReturnType.DataSource = dtTest;
                ddpReturnType.DataValueField = "ReturnType";
                ddpReturnType.DataTextField = "ReturnType";
                ddpReturnType.DataBind();
            }
        }
     
        protected void ConfirmFrom(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                List<String> listGencode = new List<String>();
                List<int> listQte = new List<int>();
                ArrayList myList = new ArrayList();
     
     
                // Récupération des datas
                for (int i = 0; i < RPT_Products.Items.Count; i++)
                {
                    Label lGencode = null;
                    TextBox tbQte = null;
     
                    lGencode = (Label)RPT_Products.Items[i].FindControl("lGencode");
                    tbQte = (TextBox)RPT_Products.Items[i].FindControl("tbQte");
     
                    if (lGencode != null && tbQte != null)
                    {
                        try
                        {
                            if (Convert.ToInt32(tbQte.Text.ToString()) > 0)
                            {
                                listGencode.Add(lGencode.Text);
                                listQte.Add(Convert.ToInt32(tbQte.Text.ToString()));
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
     
                // On ajoute à l'arraylist
                if (listGencode.Count > 0 && listQte.Count == listGencode.Count)
                {
                    myList.Add(listGencode);
                    myList.Add(listQte);
                    if (ViewState["choice"] != null)
                    {
                        myList.Add(ViewState["choice"]);
                    }
                    else
                    {
                        myList.Add(ddpReturnType.SelectedValue);
                    }
     
                    myList.Add(lTotal.Text);
     
                    if (tbReason.Text.Length > 0)
                    {
                        myList.Add(tbReason.Text);
                    }
     
                    // On met ça en session
                    Session["returnform"] = myList;
     
                    // On bouge
                    Response.Redirect("ReturnForm_Conf.aspx");
                }
            }
            else
            {
                Response.Write("<script>window.alert('Veuillez vérifier les saisies.')</script>");
            }
        }
        protected void ddpReturnType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ViewState["choice"] = ddpReturnType.SelectedValue;
        }
     
        protected void ChangeTotal(object sender, EventArgs e)
        {
                int total = 0;
     
                for (int i = 0; i < RPT_Products.Items.Count; i++)
                {
                    try
                    {
                        total += Convert.ToInt32(((TextBox)RPT_Products.Items[i].FindControl("tbQte")).Text.ToString());
                    }
                    catch (Exception)
                    {
                    }
                }
     
                lTotal.Text = total.ToString();
        }
    }
    Si je met EnableEventValidation="false"
    , IE ne me génère plus l'erreur mais le calcul du total des cartes n'est plus effectué...

    merci de m'aider

  2. #2
    Membre régulier
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Juillet 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2010
    Messages : 98
    Points : 97
    Points
    97
    Par défaut A tu trouver une réponse
    Bonjour

    Est ce que tu a trouvé une solution à ce message d'erreur, j'ai exactement le même mais je ne sais pas comment le résoudre

    Pour ma part c'est lorque je clique sur le bouton modifier dans un gridview

    Merci

Discussions similaires

  1. Réponses: 1
    Dernier message: 06/11/2013, 18h34
  2. Argument de publication ou de rappel non valide
    Par isarian dans le forum ASP.NET
    Réponses: 4
    Dernier message: 22/09/2011, 14h37
  3. Réponses: 0
    Dernier message: 28/10/2010, 23h56
  4. erreur argument de publication ou rappel non valide
    Par xavpiaf dans le forum ASP.NET
    Réponses: 1
    Dernier message: 18/06/2008, 13h51
  5. [VB.Net] cast du type 'DataRowview' en type 'Date' non valide
    Par badnane2 dans le forum Windows Forms
    Réponses: 4
    Dernier message: 14/06/2006, 15h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo