InputNumber
InputNumber
Model Binding
Features
Sample
Description
This sample shows how to use model binding features with input controls.
Use InputNumberFor() instead of InputNumber().
Source
ModelBindingController.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MvcExplorer.Models; namespace MvcExplorer.Controllers { public partial class InputNumberController : Controller { public ActionResult ModelBinding() { var model = new CustomerOrder { ID = 101, Country = "China", Count = 5, OrderTime = DateTime.Now, Product = "PlayStation 4" }; return View(model); } } }
ModelBinding.cshtml
@model MvcExplorer.Models.CustomerOrder <div> <label>@Html.Raw(Resources.InputNumber.ModelBinding_Text2)</label> @Html.C1().InputNumberFor(m => m.Count) @Html.C1().InputTimeFor(m => m.OrderTime) </div> @section Description{ <p>@Html.Raw(Resources.InputNumber.ModelBinding_Text0)</p> <p>@Html.Raw(Resources.InputNumber.ModelBinding_Text1)</p> }
Documentation