I'm not sure if this solution works on MVC3. It surely works on MVC4:
只需在渲染字段之前在Razor视图中禁用客户端验证,并在渲染字段之后重新启用客户端验证.
例子:
<div class="editor-field">
@{ Html.EnableClientValidation(false); }
@Html.TextBoxFor(m => m.BatchId, new { @class = "k-textbox" })
@{ Html.EnableClientValidation(true); }
</div>
Here we disable client side validation for the BatchId field.
Also I have developed a little helper for this:
public static class YnnovaHtmlHelper
{
public static ClientSideValidationDisabler BeginDisableClientSideValidation(this HtmlHelper html)
{
return new ClientSideValidationDisabler(html);
}
}
public class ClientSideValidationDisabler : IDisposable
{
private HtmlHelper _html;
public ClientSideValidationDisabler(HtmlHelper html)
{
_html = html;
_html.EnableClientValidation(false);
}
public void Dispose()
{
_html.EnableClientValidation(true);
_html = null;
}
}
You will use it as follow:
<div class="editor-field">
@using (Html.BeginDisableClientSideValidation()) {
@Html.TextBoxFor(m => m.BatchId, new { @class = "k-textbox" })
}
</div>
If anyone has better solutions please let me know!
Hope this help.