Je sais pas
(je dirais non : c'est pas ce que tu veux, mais oui il fait ce que tu lui as demandé )
Tu parles de quoi, ou, comment, pourquoi?
En principe si tu fais bouton droit sur ton projet => ajouter => WebForms, nommé WebForm1, c'est bon..
Je sais pas
(je dirais non : c'est pas ce que tu veux, mais oui il fait ce que tu lui as demandé )
Tu parles de quoi, ou, comment, pourquoi?
En principe si tu fais bouton droit sur ton projet => ajouter => WebForms, nommé WebForm1, c'est bon..
Chubyone, je vais pas t'aprendre aujourd'hui que je suis un que je comprend qu'un minimum de ce que l'on me dit...hein ?
Non, sérieu sa me fait toujours les méme erreurs que tout a l'heur malgré ta bonne foi et ma mienne sa ne marche pas...
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
Mmmmh...
Donne moi ton code entier de page et .cs...
Sinon il faut juste en principe :
Créer WebForm1 (soi sur qu'il n'y en a pas d autres)
Placer un TextBox dedans (avec le nom qu'il faut)
Ajouter le code que je t'ai filé (ce que tu n'a pas donc)
Lui ajouter l'évennement textchanged existant (qui ajoutes les TextBox)
Et c'est tout...
Tu ne peux pas que copier coller l'aspx, car il y a le Desginer.cs a géré aussi
Salut Chubyone,
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 protected void nbheureTextBox_TextChanged(object sender, EventArgs e) { Panel panel = new Panel(); for (int i = 0; i < Convert.ToInt32(nbheureTextBox.Text); ++i) { TextBox modele = new TextBox(); modele.ID = "text_box_child" + i; modele.Text = "Heure n° " + (i + 1); panel.Controls.Add(modele); modele.Width = 450; modele.Height = 30; } form1.Controls.Add(panel); }
C'est mon code qui me permet d'afficher autant de textbox que le nombre enter par l'utilisateur aupréalable...
Merci
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
Non, non, ca je l'avais deja modifié, je voulais dire TOUT le code (sauf les methdoe qui ne me servent pas)
ASPX compris
Voila du code :
encore du code :
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234 using System; using System.Data; using System.Collections; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data.SqlClient; using System.Text.RegularExpressions; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { nbheureanTextBox.Enabled = false ; utilisateurTextBox.Enabled = false; ModifierButton.Enabled = false; //-------------trouver le nom de l'utilisateur----------------\\ String TestLogin = System.Web.HttpContext.Current.User.Identity.Name.ToString(); String login = TestLogin.Substring(TestLogin.IndexOf('\\') + 1); string[] lastmane_User = login.Split('-'); utilisateurTextBox.Text = Convert.ToString(lastmane_User[0]); //---------------------------------------------------------\\ /* string MyConstring = "Data Source=PROD007\\SQLEXPRESS;uid=PROD007\\fraces-thomas;pwd=niouniou;Initial Catalog='C:\\BASE DE DONNÉES\\STAGE_PROJET.MDF';Integrated Security=True"; SqlConnection con = new SqlConnection(MyConstring); string queryString = "SELECT Classe.group_name FROM Dispenser INNER JOIN Formateur ON Dispenser.num_secu = Formateur.num_secu INNER JOIN Classe ON Dispenser.code_group = Classe.code_group WHERE (Formateur.teacher_lastname = '" + classeDropDownList.SelectedValue + "')"; con.Open(); SqlCommand command = new SqlCommand(queryString, con); SqlDataAdapter da = new SqlDataAdapter(command); DataTable dt = new DataTable("Classe"); da.Fill(dt); classeDropDownList.DataSource = dt; classeDropDownList.DataValueField = "group_name"; classeDropDownList.DataTextField = "group_name"; classeDropDownList.DataBind(); con.Close(); //-------------------------------------------------\\ string MyConstring1 = "Data Source=PROD007\\SQLEXPRESS;uid=PROD007\\fraces-thomas;pwd=niouniou;Initial Catalog='C:\\BASE DE DONNÉES\\STAGE_PROJET.MDF';Integrated Security=True"; SqlConnection con1 = new SqlConnection(MyConstring1); string queryString1 = "SELECT Matiere.course FROM Dispenser INNER JOIN Matiere ON Dispenser.code_course = Matiere.code_course INNER JOIN Formateur ON Dispenser.num_secu = Formateur.num_secu INNER JOIN Classe ON Dispenser.code_group = Classe.code_group WHERE (Classe.group_name = '" +classeDropDownList .SelectedValue +"')"; con1.Open(); SqlCommand command1 = new SqlCommand(queryString1, con1); SqlDataAdapter da1 = new SqlDataAdapter(command1); DataTable dt1 = new DataTable("Matiere"); da1.Fill(dt1); classeDropDownList.DataSource = dt1; classeDropDownList.DataValueField = "course"; classeDropDownList.DataTextField = "course"; classeDropDownList.DataBind(); con1.Close(); */ } protected void nomprofDropDownList_SelectedIndexChanged(object sender, EventArgs e) { } protected void okButton_Click(object sender, EventArgs e) { resultatLabel.Text = "Emploi du temps de " + utilisateurTextBox.Text + " pour la classe des " + classeDropDownList.Text + " en " + matiereDropDownList.Text; calendrier.Visible = true; string MyConstring = "Data Source=PROD007\\SQLEXPRESS;uid=PROD007\\fraces-thomas;pwd=niouniou;Initial Catalog='C:\\BASE DE DONNÉES\\STAGE_PROJET.MDF';Integrated Security=True"; SqlConnection con = new SqlConnection(MyConstring); /* try { con.Open(); SqlCommand MyCommand = new SqlCommand(); MyCommand.Connection = con; MyCommand.CommandText = "INSERT INTO Formateur ( num_secu,teacher_lastname) values ('8677845789','moitoimoimoi')"; //SqlDataReader MyDataReader; /*MyDataReader = */ // MyCommand.ExecuteReader(); // while (MyDataReader.Read()) //{ // lblClasse.Text = MyDataReader.GetString(1); // } // con.Close(); // } // catch (Exception ex) // { // Response.Write("<body><script>alert(\" " + ex.Message + "\");</script></body>"); //} nbheureTextBox.Enabled = false; nbsemaineTextBox.Enabled = false; matiereDropDownList.Enabled = false; classeDropDownList.Enabled = false; utilisateurTextBox.Enabled = false; refDropDownList.Enabled = false; refnewTextBox.Enabled = false; diplomeDropDownList.Enabled = false; ouiRadioButton.Enabled = false; nonRadioButton.Enabled = false; ModifierButton.Enabled = true; int resheurean = int.Parse(nbheureTextBox.Text) * int.Parse(nbsemaineTextBox.Text); nbheureanTextBox.Text = resheurean.ToString(); } protected void nbheureTextBox_TextChanged(object sender, EventArgs e) { Panel panel = new Panel(); for (int i = 0; i < Convert.ToInt32(nbheureTextBox.Text); ++i) { TextBox modele = new TextBox(); modele.ID = "text_box_child" + i; modele.Text = "Heure n° " + (i + 1); panel.Controls.Add(modele); modele.Width = 450; modele.Height = 30; } form1.Controls.Add(panel); } protected void nonRadioButton_CheckedChanged(object sender, EventArgs e) { if (nonRadioButton.Checked == true) { refLabel.Visible = false; refDropDownList.Visible = false; refnewLabel.Visible = true; refnewTextBox.Visible = true; réfCompareValidator.Visible = false; refnewRequiredFieldValidator.Visible = true; } } protected void ouiRadioButton_CheckedChanged(object sender, EventArgs e) { if (ouiRadioButton.Checked == true) { refLabel.Visible = true; refDropDownList.Visible = true; refnewLabel.Visible = false; refnewTextBox.Visible = false; refnewRequiredFieldValidator.Visible = false; réfCompareValidator.Visible = true; } } protected void calendrier_SelectionChanged(object sender, EventArgs e) { dateLabel.Text = "Semaine du " + calendrier.SelectedDate.ToLongDateString(); } protected void ModifierButton_Click(object sender, EventArgs e) { nbheureTextBox.Enabled = true ; nbsemaineTextBox.Enabled = true; matiereDropDownList.Enabled = true; classeDropDownList.Enabled = true; utilisateurTextBox.Enabled = true; refDropDownList.Enabled = true; refnewTextBox.Enabled = true; diplomeDropDownList.Enabled = true; ouiRadioButton.Enabled = true; nonRadioButton.Enabled = true; } }
Voila
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Programme</title> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" runat="server"> <!-- tritre --> <center ><div id="Titre" style="width: 700px; height: 46px; text-align: center;"> <asp:Label ID="titreLabel" runat="server" Text="Progression pédagogique" Width="528px"></asp:Label></div></center> <br /> <asp:TextBox ID="ouiTextBox" runat="server"></asp:TextBox> <br /> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div id="Selection" style="width: 469px; height: 494px"> <br /> <asp:Label ID="refLabel" runat="server" Text="Référentiel d'examen utilisé :" Width="203px"></asp:Label> <asp:DropDownList ID="refDropDownList" runat="server" Width="123px"> <asp:ListItem>Faite votre choix</asp:ListItem> <asp:ListItem>BO 24/09/1998</asp:ListItem> </asp:DropDownList><asp:CompareValidator ID="réfCompareValidator" runat="server" ControlToValidate="refDropDownList" ErrorMessage="/!\ 1 Aucun référentiel n'a été sélectionné" Height="16px" Operator="NotEqual" Style="position: static" ValueToCompare="Faite votre choix">/!\ 1</asp:CompareValidator><br /> <br /> <asp:Label ID="qestLabel" runat="server" Text="Avez-vous trouvé le référentiel qu'il vous faut ?" Width="322px"></asp:Label><asp:RadioButton ID="ouiRadioButton" runat="server" Text="oui" GroupName="ref" AutoPostBack="True" Checked="True" OnCheckedChanged="ouiRadioButton_CheckedChanged" Height="20px" Width="40px" /><asp:RadioButton ID="nonRadioButton" runat="server" Text="non" GroupName="ref" AutoPostBack="True" Height="20px" OnCheckedChanged="nonRadioButton_CheckedChanged" Width="40px" /><br /> <br /> <asp:Label ID="refnewLabel" runat="server" Text="Enter un nouveau référentiel :" Width="208px" Visible="False"></asp:Label> <asp:TextBox ID="refnewTextBox" runat="server" Visible="False" Height="16px" Width="153px" ></asp:TextBox> <asp:RequiredFieldValidator ID="refnewRequiredFieldValidator" runat="server" ControlToValidate="refnewTextBox" ErrorMessage="/!\ 2 Il vous faut obligatoirement saisir un référentiel" Style="position: static" Visible="False">/!\ 2</asp:RequiredFieldValidator><br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="nomprofLabel" runat="server" Text="Nom du professeur :"></asp:Label> <asp:TextBox ID="utilisateurTextBox" runat="server" Width="84px" AutoPostBack="True" Height="16px"></asp:TextBox><br /> <br /> <asp:Label ID="classeLabel" runat="server" Text="Classe :"></asp:Label><asp:DropDownList ID="classeDropDownList" runat="server" Height="22px" Width="140px" > <asp:ListItem>Faite votre choix</asp:ListItem> <asp:ListItem>ou</asp:ListItem> </asp:DropDownList><asp:CompareValidator ID="classeCompareValidator" runat="server" ControlToValidate="classeDropDownList" ErrorMessage="/!\ 4 Aucune classe n'a été sélectionné" Style="position: static" ValueToCompare="Faite votre choix" Operator="NotEqual">/!\ 4</asp:CompareValidator> <br /> <br /> <asp:Label ID="matiereLabel" runat="server" Text="Matiére :"></asp:Label><asp:DropDownList ID="matiereDropDownList" runat="server" Height="22px" Width="140px"> <asp:ListItem>Faite votre choix</asp:ListItem> <asp:ListItem>ou</asp:ListItem> </asp:DropDownList><asp:CompareValidator ID="matiereCompareValidator" runat="server" ControlToValidate="matiereDropDownList" ErrorMessage="/!\ 5 Aucune matiére n'a été sélectionné" Style="position: static" ValueToCompare="Faite votre choix" Operator="NotEqual">/!\ 5</asp:CompareValidator><br /> <br /> <asp:Label ID="diplomeLabel" runat="server" Text="Diplôme préparé :" Width="125px"></asp:Label><asp:DropDownList ID="diplomeDropDownList" runat="server" Width="212px"> <asp:ListItem>Faite votre choix</asp:ListItem> <asp:ListItem>ou</asp:ListItem> </asp:DropDownList><asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="diplomeDropDownList" ErrorMessage="/!\ 6 Aucune diplôme n'a été sélectionné" Operator="NotEqual" Style="position: static" ValueToCompare="Faite votre choix">/!\ 6</asp:CompareValidator> <br /> <br /> <asp:Label ID="nbheureLabel" runat="server" Text="Nombre d'heures de cour par semaine :" ></asp:Label> <asp:TextBox ID="nbheureTextBox" runat="server" Width="30px" OnTextChanged="nbheureTextBox_TextChanged" Height="22px" ></asp:TextBox> <asp:RegularExpressionValidator ID="MonRegularExpression" runat="server" ControlToValidate="nbheureTextBox" ErrorMessage="/!\ 7 Vous devez saisir un nombre !!!" SetFocusOnError="true" ValidationExpression="\d+">/!\ 7</asp:RegularExpressionValidator> <asp:RequiredFieldValidator ID="nbsemaineRequiredFieldValidator" runat="server" ControlToValidate="nbheureTextBox" ErrorMessage="/!\ 8 Il vous faut obligatoirement saisir un nombre de semaine " Style="position: static">/!\ 8</asp:RequiredFieldValidator> <asp:CompareValidator ID="nbheureCompareValidator" runat="server" ControlToValidate="nbheureTextBox" ErrorMessage="/!\ 9 Comment pouvez vous travaillé plus de 50 h par semaine ?! " Operator="LessThan" Style="position: static" ValueToCompare="51" Type="Integer">/!\ 9</asp:CompareValidator> <br /> <br /> <asp:Label ID="nbsemaineLabel" runat="server" Text="Nombre de semaines :" ></asp:Label> <asp:TextBox ID="nbsemaineTextBox" runat="server" Width="30px" Height="22px" style="position: static" ></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="nbsemaineTextBox" ErrorMessage="/!\ 10 Vous devez saisir un nombre !!!" SetFocusOnError="true" ValidationExpression="\d+">/!\ 10</asp:RegularExpressionValidator> <asp:RequiredFieldValidator ID="nbheureRequiredFieldValidator" runat="server" ControlToValidate="nbsemaineTextBox" ErrorMessage="/!\ 11 Il vous faut obligatoirement saisir un nombre d'heures " Style="position: static">/!\ 11</asp:RequiredFieldValidator> <asp:CompareValidator ID="nbsemaineCompareValidator" runat="server" ControlToValidate="nbsemaineTextBox" ErrorMessage="/!\ 12 Une année ne comporte que 52 semaines !!!" Operator="LessThan" Style="position: static" ValueToCompare="53" Type="Integer">/!\ 12</asp:CompareValidator> <br /> <br /> <asp:Label ID="heureanLabel" runat="server" Text="Nombre d'heures de cour pas an :" Width="230px"></asp:Label> <asp:TextBox ID="nbheureanTextBox" runat="server" Width="30px" Height="22px" BackColor="Silver"></asp:TextBox> <br /> <br /> <br /> <br /> <asp:Button ID="okButton" runat="server" OnClick="okButton_Click" Text="OK" Width="141px" /> <asp:Button ID="ModifierButton" runat="server" OnClick="ModifierButton_Click" Text="Modifier" Width="145px" /><br /> <br /> <br /> <br /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server"> </ajaxToolkit:CascadingDropDown> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server"> </ajaxToolkit:CascadingDropDown> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server"> </ajaxToolkit:CascadingDropDown> <br /> <br /> <br /> </ContentTemplate> </asp:UpdatePanel> <br /> <center> </center> <center> </center> </div> <br /> <div style="z-index: 100; left: 499px; width: 264px; position: absolute; top: 139px; height: 293px"> <asp:Label ID="resultatLabel" runat="server" Width="492px"></asp:Label><br /> <br /> <br /> <asp:Calendar ID="calendrier" runat="server" OnSelectionChanged="calendrier_SelectionChanged" SelectionMode="DayWeek" Style="position: static;" Visible="False" Width="1px" Height="1px" BackColor="White"></asp:Calendar> <br /> <asp:Label ID="dateLabel" runat="server" Style="position: static" Width="315px"></asp:Label></div> <div id="Erreur" style="width: 100px; height: 1px"> <asp:ValidationSummary ID="erreurValidationSummary" runat="server" BackColor="Transparent" Width="475px" Height="21px" /> </div> </form> </body> </html>
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
En fait je souhaitais le code de la nouvelle page...
Créer une page WebForm1, avec RIEN dedans : absolument RIEN : pas de scriptmanager, pas d'updatepanel, pas de ControlToolkit, queutchi!
Ensuite ajoute une simple TextBox, et son evennement textchanged.
Ajoute le code que je tai filé plus haut, et fais le marcher...
Ensuite on verra avec Ajax et les controltoolkit... Commence deja par faire marcher ce que tu veux à blanc...
Tu devrais te retrouver avec une aspx similaire a la mienne (voir identique)
J'ai fait exactement ce que tu m'as dit et il m'affiche encore et toujours des erreurs...
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
Exactement les memes?
C'est inquiétant si tu ne peux meme pas ajouter une simple page blanche...
Il va te falloir fouiller un peu le pourquoi des erreurs... Vas y pas a pas et dès que ca bloque, analyse pourquoi.
C'est ce que j'essai de faire ne t'inquiette pas je me ratache pas qu'a toi...je ne sais pas d'ou sa vien ça me gonffle c'est sur que sa vien pas du code behind ?
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
Si tu fais bouton droit "ajouter une webform" il genere tout comme il faut la page...
Les erreurs -a vu de nez- proviennent d'une erreur de nommage, de référence de namespace, ou d'héritage...
Pourtant je fait tout ce qui a de normal...
-Je crée un nouveau siteweb
-le webform et déja présent ( Defaut.aspx)
-je le renome en WebForm1
-je copie/colle le code .aspx que tu m'a donné
-j'ouvre WebForm1.aspx.cs
-je copie/colle le code .cs que tu m'as donné...
et c'est tout...
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
NE copie colle pas tout de suite.
Tu as remarqué que dans mon aspx, dans mon Inherits j'ai aussi le namespace? TU dois l'adapter au tiens
Mon .cs idem : adatpte le namespace.
Ensuite n'oubli pas les using que j'ai placé en plus.
Merci, ça marche !!! j'ai enlever le textchange par contre...
Je sais pas si c'est car je sais méme pas a quoi ça sert...
Je vais maintenat l'adapter a mon code
Merci de ta patience je te recontacte...
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
Salut,
Je suis plus ou moins arrivé a adapter mon code...
Le seul IC' c'est que qand le premier message se copie dans les TextBox suivante la page se rechagre et donc "remonte" y'a t'il une solution pour éviter cela ?
Merci
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
Oui, l'evennement TextChanged des textbox contenant du text doit se faire en javascript... sauf que ca sera chiant de récup les valeur apres...
Si tu utilise ajax ailleurs, ca peut etre une solution : seul l'updatepanel sera raffraichit, celui qui contient les textbox.
Pour cela, tu dois adapter le code à ajax, et les insérer dans un updatepanel plutot que la form (ca c'est en théorie humaine : techniquement, c'est plus chiant )
Ensuite fais attention : l'vennement textchanged se déclenche au chagement de texte : si tu ative leur autopostback, a chaque changement, il y aura un post, ca sera l'enfer
Oué je sais j'ai déja du tester l' AJAX et c'est + que chiant c'est pas grave c'est déja trés bien comme ça...Je te cache pas que j'ai eu quelques propléme a l'adaptation de mon code...
"Ne faites pas à autrui ce que vous pouvez faire le jour même."
[Francis Blanche]
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager