1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
using System.ComponentModel.DataAnnotations; namespace UnitTestArticle.Models { public class TransferMoneyModel { [Display(Name ="Source Account Number")] [Required] [MinLength(10), MaxLength(10)] public string SourceAccountNumber { get; set; } [Display(Name = "Destination Account Number")] [Required] [MinLength(10), MaxLength(10)] public string DestinationAccountNumber { get; set; } [Display(Name = "Amount")] [Required] [Range(0.01,1000000)] public decimal Amount { get; set; } } } |
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 |
@model TransferMoneyModel @{ ViewBag.Title = "TransferMoney"; } <h2>Transfer Money</h2> @Html.ValidationSummary() @using (Html.BeginForm()) { <div class="form-group"> @Html.LabelFor(m => m.SourceAccountNumber) @Html.TextBoxFor(m => m.SourceAccountNumber, new { @class = "form-control" }) </div> <div class="form-group"> @Html.LabelFor(m => m.DestinationAccountNumber) @Html.TextBoxFor(m => m.DestinationAccountNumber, new { @class = "form-control" }) </div> <div class="form-group"> @Html.LabelFor(m => m.Amount) @Html.TextBoxFor(m => m.Amount, new { @class = "form-control", type="number" }) </div> <button type="submit" class="btn btn-primary">Transfer</button> } |