Asp.Mvc 2.0用户登录实例讲解---(4)服务器端验证(10)
public override string FormatErrorMessage(string name)
{
return ErrorMessage;
}
/// <summary>
/// 重写TYPEID
/// </summary>
public override object TypeId
{
get
{
return _typeid;
}
}
/// <summary>
/// 判断是否想到
/// </summary>
/// <param name="value">value的值实际上是MODEL提交的MODEL类</param>
/// <returns></returns>
public override bool IsValid(object value)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value);
object originalValue = properties.Find(PWD, true ).GetValue(value);//获取密码
object confirmValue = properties.Find(ConfirmPwd, true).GetValue(value);//获取确认密码的值
return Object.Equals(originalValue, confirmValue);
}
}
前台页面代码
[html] <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MvcLogin.Models.RegisterModel>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>注册页面</title>
<script type="text/javascript" src="../../Scripts/jquery-1.4.1-vsdoc.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.validate.js"></script>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>