Bonjour,
mes champs sont vidés/effacés apres un clic sur un boutton d'enregistrement , pourquoi ?
Du coup j'enregistre du vide avec ma requette
J'ai des champs qui sont réinitialisés,comme si la page était rechargée.
Bonjour,
mes champs sont vidés/effacés apres un clic sur un boutton d'enregistrement , pourquoi ?
Du coup j'enregistre du vide avec ma requette
J'ai des champs qui sont réinitialisés,comme si la page était rechargée.
Ne serait-ce pas un soucis de PostBack ?
Ou tu pourrais nous montrer un bout de code.
je pense aussi que c'est ça. Je ne suis pas au taff mais si c'est le cas, comment le regler ?
Merci !
voici le code html :
La balise form de la masterpage est en method="Post"
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 <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="MyProfile.aspx.cs" Inherits="MyProfile" Title="Page sans titre" %> <%@ Register assembly="Artem.GoogleMap" namespace="Artem.Web.UI.Controls" tagprefix="artem" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <table> <tr><td> <table> <tr> <td align="right"><asp:Label ID="LabelPseudo" runat="server" Text="Nom utilisateur"></asp:Label></td> <td align="left"> <asp:TextBox ID="Pseudo" runat="server" AutoPostBack="True"></asp:TextBox></td> </tr> <tr> <td align="right"><asp:Label ID="LabelEmail" runat="server" Text="Email"></asp:Label></td> <td align="left" > <asp:TextBox ID="Email" runat="server" Width="300px" ></asp:TextBox></td> </tr> <tr> <td align="right"><asp:Label ID="LabelNom" runat="server" Text="Nom"></asp:Label></td> <td align="left"><asp:TextBox ID="Nom" runat="server"></asp:TextBox></td> </tr> <tr> <td align="right"><asp:Label ID="LabelPrenom" runat="server" Text="Prénom"></asp:Label></td> <td align="left"><asp:TextBox ID="Prenom" runat="server"></asp:TextBox></td> </tr> <tr> <td align="right"> <asp:Label ID="LabelAdresse" runat="server" Text="Adresse"></asp:Label></td> <td align="left"><asp:TextBox ID="adresse1" runat="server" Width="300px"></asp:TextBox></td> </tr> <tr> <td align="right"><asp:Label ID="LabelAdresse2" runat="server" Text="Complément"></asp:Label></td> <td align="left"><asp:TextBox ID="adresse2" runat="server" Width="300px"></asp:TextBox></td> </tr> <tr> <td align="right"> <asp:Label ID="LabelCP" runat="server" Text="Code Postal"></asp:Label></td> <td align="left"><asp:TextBox ID="CP" runat="server"></asp:TextBox></td> </tr> <tr> <td align="right"> <asp:Label ID="LabelVille" runat="server" Text="Ville"></asp:Label></td> <td align="left"><asp:TextBox ID="Ville" runat="server" Width="300px"></asp:TextBox></td> </tr> <tr> <td align="right"> <asp:Label ID="LabelPays" runat="server" Text="Pays"></asp:Label></td> <td align="left"><asp:DropDownList id="Pays" runat="server"> <asp:ListItem Value="" Selected="true">Choisir un Pays</asp:ListItem> <asp:ListItem Value="AF">Afghanistan</asp:ListItem> <asp:ListItem Value="AL">Albania</asp:ListItem> </asp:DropDownList></td> </tr> <tr><!-- bouton valider--> <td align="center"></td> <td align="left"> <asp:Button ID="Button1" runat="server" Text="VALIDER" Width="166px" BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" ForeColor="#A7C520" onclick="Button1_Click"/> </td> </tr> <tr> <td align="center"></td> <td align="center"> <a href="ChangePassword.aspx">Changer votre mot de passe</a> </td> </tr> </table> </td> <td><!-- espace googlemap--> <div> <artem:GoogleMap ID="GoogleMap1" runat="server"> </artem:GoogleMap> </div> </td></tr></table> </asp:Content>
le code c# :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 protected void Button1_Click(object sender, EventArgs e) { // Populate some Profile properties off of the create user wizard Profile.Nom = this.Nom.Text; Profile.Prénom = this.Prenom.Text; Profile.Adresse1 = this.adresse1.Text; Profile.Adresse2 = this.adresse2.Text; Profile.CP = this.CP.Text; Profile.Ville = this.Ville.Text; Profile.Pays = this.Pays.SelectedValue; }
tu as mis enableviewstate=true dans tes controls?
Partager