Bonjour,
Je débute une appli en ASP.Net C# en MVC avec Visual Studio 2010, j'ai cherché des tuto dans tous les sens mais je me galère.
Ne vous attendez pas à du code de haut vol. Je me suis lancé là dedans sans grandes connaissances...
Donc, bêtement, j'essaie de modifier mes données et j'ai l'erreur que j'ai mis en pièce jointe qui ne me parle pas du tout.
J'ai ce même message lorsque j'essaie de créer un enregistrement. Le code ne passe pas dans les méthodes et je ne sais pas quoi debug...
je devrais passer dans /Appel/Details/
Le code du controller :
le code de la vue :
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 namespace HotLine.Controllers { public class AppelController : Controller { protected static List<AppelModels> appels = new List<AppelModels>(); public AppelController() { } // // GET: /Appel/ public ActionResult Index() { appels.Clear(); AppelModels.Init(ref appels); return View(appels); } // // GET: /Appel/Details/1 public ActionResult Details(int id) { var appelToGet = (from c in appels where c.Ticket == id select c).FirstOrDefault(); return View(appelToGet); } // // POST: /Appel/Details [AcceptVerbs(HttpVerbs.Post)] public ActionResult Details(AppelModels appel) { Response.Write("Test"); if (!ModelState.IsValid) return View(); try { var monAppel = (from c in appels where c.Ticket == appel.Ticket select c).FirstOrDefault(); monAppel.Update(appel); int monIndex = appels.IndexOf(monAppel); //appels.RemoveAt(monIndex); //appels.Insert(monIndex, appel); return RedirectToAction("Index"); } catch { return View(); } } }
Le message apparaît quand je submit le formulaire.
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 <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<HotLine.Models.AppelModels>" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Details</title> </head> <body> <form action = "/Appel/Details/" method = "post"> <fieldset> <legend>Fields</legend> <div class="editor-label"> <%: Html.LabelFor(model => model.Ticket) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Ticket) %> <%: Html.ValidationMessageFor(model => model.Ticket) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Tiers) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Tiers) %> <%: Html.ValidationMessageFor(model => model.Tiers) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Intitule) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Intitule) %> <%: Html.ValidationMessageFor(model => model.Intitule) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.NumeroContact) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.NumeroContact) %> <%: Html.ValidationMessageFor(model => model.NumeroContact) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Affaire) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Affaire) %> <%: Html.ValidationMessageFor(model => model.Affaire) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Origine) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Origine) %> <%: Html.ValidationMessageFor(model => model.Origine) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Nature) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Nature) %> <%: Html.ValidationMessageFor(model => model.Nature) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Importance) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Importance) %> <%: Html.ValidationMessageFor(model => model.Importance) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Logiciel) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Logiciel) %> <%: Html.ValidationMessageFor(model => model.Logiciel) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Module) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Module) %> <%: Html.ValidationMessageFor(model => model.Module) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Fonction) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Fonction) %> <%: Html.ValidationMessageFor(model => model.Fonction) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Connaissance) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Connaissance) %> <%: Html.ValidationMessageFor(model => model.Connaissance) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Question) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Question) %> <%: Html.ValidationMessageFor(model => model.Question) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Etat) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Etat) %> <%: Html.ValidationMessageFor(model => model.Etat) %> </div> </fieldset> <input type = "submit" value = "Edit" /> </form> <p> <%: Html.ActionLink("Back to List", "Index") %> </p> </body> </html>
S'il vous faut plus d'éléments, n'hésitez pas.
Merci par avance.
Partager