interaction bouton formulaire
Hello les noob,
.Net Framework 4.5.2
MVC Version=5.2.3.0
Donc j'ai une page avec un formulaire et un bouton.
J'aimerais savoir comment à partir de ce bouton je peux afficher quelques chose dans un label ou autres en dessous du bouton en fonction des données entrées par l'utilisateur en input.
Code:
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
|
@using WebApplication1.Models
@model PricerViewModels
@{
ViewBag.Title = "SwapVanille";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("SwapVanille", "Pricer", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Veuillez donner les caractéristiques de votre Swap/</h4>
<hr />
<div id="Leg1">
<h4>Leg 1</h4>
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.Notionnel1, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.Notionnel1, new { @class = "form-control" })
</div>
@Html.LabelFor(m => m.TauxFixe, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.TauxFixe, new { @class = "form-control" })
</div>
@Html.LabelFor(m => m.start_date1, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.start_date1, new { @class = "form-control" })
</div>
@Html.LabelFor(m => m.end_date1, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.end_date1, new { @class = "form-control" })
</div>
</div>
</div>
<div id="Leg2">
<h4>Leg 2</h4>
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.Notionnel2, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.Notionnel2, new { @class = "form-control" })
</div>
@Html.LabelFor(m => m.start_date2, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.start_date2, new { @class = "form-control" })
</div>
@Html.LabelFor(m => m.end_date2, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.end_date2, new { @class = "form-control" })
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Pricer SWAP" />
</div>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
} |
Code:
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
|
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace WebApplication1.Models
{
public class PricerViewModels
{
//LEG 1
[Required]
[Display(Name = "Notionnel")]
public string Notionnel1 { get; set; }
[Required]
[Display(Name = "Taux Fixe (en %) : ")]
public string TauxFixe { get; set; }
[Required]
[Display(Name = "Start Date (yyyymmdd) : ")]
public string start_date1 { get; set; }
[Required]
[Display(Name = "End Date (yyyymmdd) : ")]
public string end_date1 { get; set; }
//prix de la leg 1
[Required]
[Display(Name = "Prix de la Leg 1")]
public string price_leg1 { get; set; }
//####################" LEG 2
[Required]
[Display(Name = "Notionnel")]
public string Notionnel2 { get; set; }
[Required]
[Display(Name = "Start Date (yyyymmdd) :")]
public string start_date2 { get; set; }
[Required]
[Display(Name = "End Date (yyyymmdd) : ")]
public string end_date2 { get; set; }
//prix de la leg 2
[Required]
[Display(Name = "Prix de la Leg 2")]
public string price_leg2 { get; set; }
}
} |
Code:
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
|
using System;
using System.Globalization;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class PricerController : Controller
{
[HttpGet]
// GET: Pricer
public ActionResult SwapVanille()
{
return View();
}
[HttpPost]
public ActionResult SwapVanille(string notionnel1)
{
return View();
}
}
} |
Merci pour votre aide.
Dumbl