Bonjour,
J'ai un formulaire d'inscription et je veux que lors d'un clique sur le bouton 'Create' tous ces informations seront enregistrés dans la base de données plu exactement dans ma table "Vendeur" et un mail envoyé à l'utilisateur qui a fait l'inscrit sur le mail qui la saisir au moment de l'inscrit.
Bon j'ai réussit a faire cette formulaire et enregistrer ces information dans ma table mai je suis bloqué au niveau de l'envoi du mail.
comment le faire en utilisant asp.net mvc 3 ?
Voila mon view de l'inscription:
et voila mon controlleur:
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 @model PFE.Models.Vendeur @{ ViewBag.Title = "Inscription"; } <h2>Inscription</h2> <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>Vendeur</legend> <div class="editor-label"> @Html.LabelFor(model => model.NOM) </div> <div class="editor-field"> @Html.EditorFor(model => model.NOM) @Html.ValidationMessageFor(model => model.NOM) </div> <div class="editor-label"> @Html.LabelFor(model => model.TEL1) </div> <div class="editor-field"> @Html.EditorFor(model => model.TEL1) @Html.ValidationMessageFor(model => model.TEL1) </div> <div class="editor-label"> @Html.LabelFor(model => model.TEL2) </div> <div class="editor-field"> @Html.EditorFor(model => model.TEL2) @Html.ValidationMessageFor(model => model.TEL2) </div> <div class="editor-label"> @Html.LabelFor(model => model.FAX) </div> <div class="editor-field"> @Html.EditorFor(model => model.FAX) @Html.ValidationMessageFor(model => model.FAX) </div> <div class="editor-label"> @Html.LabelFor(model => model.ADRESSE) </div> <div class="editor-field"> @Html.EditorFor(model => model.ADRESSE) @Html.ValidationMessageFor(model => model.ADRESSE) </div> <div class="editor-label"> @Html.LabelFor(model => model.CODEP) </div> <div class="editor-field"> @Html.EditorFor(model => model.CODEP) @Html.ValidationMessageFor(model => model.CODEP) </div> <div class="editor-label"> @Html.LabelFor(model => model.VILLE) </div> <div class="editor-field"> @Html.EditorFor(model => model.VILLE) @Html.ValidationMessageFor(model => model.VILLE) </div> <div class="editor-label"> @Html.LabelFor(model => model.PAYS) </div> <div class="editor-field"> @Html.EditorFor(model => model.PAYS) @Html.ValidationMessageFor(model => model.PAYS) </div> <div class="editor-label"> @Html.LabelFor(model => model.MAIL) </div> <div class="editor-field"> @Html.EditorFor(model => model.MAIL) @Html.ValidationMessageFor(model => model.MAIL) </div> <div class="editor-label"> @Html.LabelFor(model => model.CODE) </div> <div class="editor-field"> @Html.EditorFor(model => model.CODE) @Html.ValidationMessageFor(model => model.CODE) </div> <div class="editor-label"> @Html.LabelFor(model => model.Type) </div> <div class="editor-field"> @Html.EditorFor(model => model.Type) @Html.ValidationMessageFor(model => model.Type) </div> <p> <input type="submit" value="Create" /> </p> </fieldset> } <div> @Html.ActionLink("Back to List", "Index") </div>
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 using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Web; using System.Web.Mvc; using PFE.Models; using System.Web.Helpers; namespace PFE.Controllers { public class InscriptionController : Controller { private WEBMEDEntities1 db = new WEBMEDEntities1(); // // GET: /Inscription/ public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(Vendeur vendeur) { if (ModelState.IsValid) { db.Vendeur.AddObject(vendeur); db.SaveChanges(); return RedirectToAction("Confirmation", "Confirmation");//redireger vers une page contenet un message "Pour confirmer l'inscription,un mail de validation sera envoyé sur l'adresse mail que vous avez saisir au momant de l'inscription" } return View(); } } }
et le model générer a partir de la base de données.
Merci d'avance.
Partager