启用剃刀看法客户端验证(ASP MVC 3) [英] Enable client validation in Razor views (ASP MVC 3)

查看:138
本文介绍了启用剃刀看法客户端验证(ASP MVC 3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用下面这行code的添加客户端验证:

I try to add client side validation using this line of code:

@ Html.EnableClientValidation()

不过,我不断收到此错误消息:

But I keep getting this error message:

编译器错误信息:CS1502:为了获得最佳重载方法匹配'Microsoft.WebPages.WebPageUltimateBase.Write(Microsoft.WebPages.Helpers.HelperResult)'有一些无效参数

这是工作的其他人,或者是在ASP这种另一种方法MVC 3?

Is this working for anyone else, or is it another approach for this in ASP MVC 3?

推荐答案

可以,相反,使用到位code的预期线以下。

You can, instead, use the following in place of the expected line of code.

@(ViewContext.ClientValidationEnabled = true)

大概在扩展方法的HtmlHelper监督。

Probably an oversight in the extension methods for htmlhelper.

其实,你可以通过做使用的HtmlHelper方法如下

Actually, you can use the HtmlHelper method by doing the following

@{ Html.EnableClientValidation(); }

这篇关于启用剃刀看法客户端验证(ASP MVC 3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆