首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

mvc model远程Remote验证碰到的有关问题

2012-12-28 
mvc model远程Remote验证碰到的问题model: [Remote(CheckUserNameExists, Category, ErrorMessage

mvc model远程Remote验证碰到的问题
model:
 [Remote("CheckUserNameExists", "Category", ErrorMessage = "名字已存在")] 
        public override string Name
        {
            get
            {
                return base.Name;
            }
            set
            {
                base.Name = value;
            }
        }
controller:
 [HttpGet]
        public ActionResult CheckUserNameExists()
        {
            string name = Request["name"];
            string id = Request["id"] as string;//添加的时候没有id
            return Json(string.IsNullOrEmpty(id) ? !new BackendDBContext().Categories.Any(o => o.Name == name) : !new BackendDBContext().Categories.Any(o => o.Name==name&&o.ID != Convert.ToInt32(id)), JsonRequestBehavior.AllowGet);

        } 
这样设计如果在添加的时候没有问题,但是在编辑的时候我想把需要编辑的model.id传进去、怎么传到验证的方法中去啊?有没有办法请各位高人指教一下....
[解决办法]
没人回答啊怎么

热点排行