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:
[QUOTE]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.[/QUOTE]
Voici mon code returnform2.aspx:
[CODE]<%@ 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>
</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>
[/CODE]
Voici mon code returnform2.aspx.cs:
[CODE]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();
}
}
[/CODE]
Si je met [B]EnableEventValidation="false"[/B]
, IE ne me génère plus l'erreur mais le calcul du total des cartes n'est plus effectué...
au secours, vraiment j'en peux plus là !