public ActionResult ValidateTestName(string testName) { return Json(!testName.Equals("test"), JsonRequestBehavior.AllowGet); }
using System.ComponentModel.DataAnnotations; using System.Web.Mvc; namespace MvcApplication1.Models { public class AboutModel { [Required] [Remote("ValidateTestName", "Home", ErrorMessage = "this Name already be used.")] public string TestName { get; set; } [Required] [Range(20, 44)] public int Age { get; set; } } }
@model MvcApplication1.Models.AboutModel @{ ViewBag.Title = "About Us"; } About Put content here. @using (Html.BeginForm()) { @Html.EditorForModel(); "submit" value="Submit" /> }
Put content here. @using (Html.BeginForm()) { @Html.EditorForModel(); "submit"
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, u