これは私のasp.netmvc2プロジェクトのモデルです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.DynamicData;
using System.Web.Security;
using System.Globalization;
using System.Web.Profile;
namespace EMS.Models
{
public class UserModels
{
    [Required(ErrorMessage = "*")]
    public string userName { get; set; }
    [Required(ErrorMessage = "*")]
    public string passWord { get; set; }
  }
}
そしてこれは私の見解です:
 <% Html.EnableClientValidation(); %>
    <% using (Html.BeginForm()) { %>
    <table>
            <tr>
                <td><label for="userlogin">User Login:</label></td>
                <td>
                    <%: Html.TextBoxFor(m => m.userName, new { id = "userName"})%> 
                    <%: Html.ValidationMessageFor(m => m.name)%>
                </td>
                <td><label for="password">Password:</label></td>
                <td>
                    <%: Html.PasswordFor(m => m.passWord, new { id = "password"})%> 
                    <%: Html.ValidationMessageFor(m => m.passWord)%>
                </td>
             </tr>
            <tr>
                <td colspan="4">
                      <input type="submit"  name="enter_infor" id="enter_infor" value="Enter Information"/>
                </td>
            </tr>
    </table>
そしてこれは私のコントローラーです:
    [HttpPost]
    public ActionResult UserMaintenance(FormCollection frm)
    {
        UserModels candidate = new UserModels
        {
            userName = frm["userName"].ToString(),
            passWord = frm["passWord"].ToString()
       };
       DBSEntities context = new DBSEntities();
       UserName user = new UserName();
       context.AddToUserNames(user);
       context.SaveChanges();
       return View();
    }
問題:ユーザーがユーザー名とパスワードのテキストボックスの両方を入力したかどうかを検証したい。しかし、上記のすべてのコードで、ユーザーは検証メッセージなしでコードを送信できます。スクリプトをSite.Masterに含めました。誰でも教えてくれます、何が間違っていたのですか?
ありがとう。