asp.net-mvc – 如何使用Asp.net MVC验证列表属性是否具有最小项
发布时间:2020-12-16 03:19:31 所属栏目:asp.Net 来源:网络整理
导读:我有一个视图模型,其属性看起来像这样 Property SelectedGroups() as List(of string) 在视图中我有这样的东西 table tr thDescription/th /tr tr td input type="hidden" name="SelectedGroups" value="one" / description one /td /tr tr td input type="h
我有一个视图模型,其属性看起来像这样
Property SelectedGroups() as List(of string) 在视图中我有这样的东西 <table> <tr> <th>Description</th> </tr> <tr> <td> <input type="hidden" name="SelectedGroups" value="one" /> description one </td> </tr> <tr> <td> <input type="hidden" name="SelectedGroups" value="two" /> description two </td> </tr> <tr> <td> <input type="hidden" name="SelectedGroups" value="three" /> description three </td> </tr> </table> 使用jquery添加和删除表行.有没有办法在SelectedGroups属性上创建一个验证属性,该属性需要列表的最小项目数?这可以用javascript完成,但我希望它可以使用 <% Html.EnableClientValidation()%> <%: Html.ValidationSummary(False)%> 解决方法
您必须编写自定义验证器.内置的验证器并不复杂.
ScottGu撰写了一篇关于自定义验证器的文章:http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 从URL mvc中省略控制器名称
- asp.net – IIS 7.5无法打开处理程序映射?
- asp.net – 性能缓慢的Azure’Web App’Azure SQL DB
- asp.net – SQL Server集成身份验证模式
- 从2.0到3.5的ASP.NET框架效应?
- asp.net-mvc – 什么可能导致一个503服务不适用于asp.net m
- ASP.NET (C#) 数据库-01_ADO_NET-04_DataSet-07_TableMappi
- .net – 使用UrlHelper.Action方法生成网址时,引用异常
- .net – SqlConnection的Dispose方法是否会干扰连接池?
- asp.net-mvc – MapMvcAttributeRoutes:此方法不能在应用程
推荐文章
站长推荐
- asp.net-mvc-3 – 如何在Mvccontrib网格模型中使
- 使用Asp.net核心将PDF返回到浏览器
- ASP.NET页面动态添加js脚本
- asp.net – EF更新记录属性后在SaveChanges()上抛
- asp.net-mvc – MVVM ViewModel vs. MVC ViewMod
- asp.net – 如何保护web.config中的connectionst
- asp.net-mvc – 是否可以使用实体框架代码首先设
- asp.net-core – 在ASP.NET MVC Core中仍然存在V
- 在ASP.NET类中访问响应对象
- asp.net – 在为app_offline.htm提供特定URL时,将
热点阅读