I have a simple strongly-typed view.
@model GoldForGold.Models.LogonModel
@{
ViewBag.Title = \"Logins\";
Layout = \"~/Views/Shared/_Layout.cshtml\";
Here is the complete solution:
Add the following scripts to your view:
Enable Validation in Web.Config:
Add validation element in the view:
@Html.ValidationMessageFor(model => model.UserName)
Add Required attribute to you model`s element.
[Required(ErrorMessage="please enter username")]
public string UserName { get; set; }