I try to add client side validation using this line of code:
@Html.EnableClientValidation()
But I keep getting this error message:
Compiler Error Message: CS1502: The best overloaded method match for 'Microsoft.WebPages.WebPageUltimateBase.Write(Microsoft.WebPages.Helpers.HelperResult)' has some invalid arguments
Is this working for anyone else, or is it another approach for this in ASP MVC 3?
We can enable and disable the client-side validation by setting the values of ClientValidationEnabled & UnobtrusiveJavaScriptEnabled keys true or false. This setting will be applied to application level. For client-side validation, the values of above both the keys must be true.
In the server-side validation, the page must be submitted via a postback to be validated on the server and if the model data is not valid then the server sends a response back to the client with client-side validation, the input data is checked as soon as they are submitted, so there is no postback to the server and ...
You can simply disable client side validation in the Razor view prior to render the field and re-enable client side validation after the field has been rendered.
You can, instead, use the following in place of the expected line of code.
@(ViewContext.ClientValidationEnabled = true)
Probably an oversight in the extension methods for htmlhelper.
Actually, you can use the HtmlHelper method by doing the following
@{ Html.EnableClientValidation(); }
Hey, in ASP.NET MVC3, there's no need to add Html.EnableClientValidation() in view page, instead, just enable the clientValidation in the webconfig file as below:
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
this tag
@{ Html.EnableClientValidation(false); }
must come before the
@using (Html.BeginForm())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With