Asp.net mvc 3 客户端数据批注验证在使用firefox和chrome的局部视图上不起作用
我的asp.net mvc web应用程序中有以下主视图:-Asp.net mvc 3 客户端数据批注验证在使用firefox和chrome的局部视图上不起作用,asp.net-mvc-3,data-annotations,Asp.net Mvc 3,Data Annotations,我的asp.net mvc web应用程序中有以下主视图:- <table> <tr> <th> Lab Test </th> <th> Result </th> <th> Date Taken </th> <th>
<table>
<tr>
<th>
Lab Test
</th>
<th>
Result
</th>
<th>
Date Taken
</th>
<th>
Comment
</th>
<th>
</th>
@for (int item = 0; item < 10; item++)
{
using (Ajax.BeginForm("CreateAll", "VisitLabResult", new AjaxOptions
{
HttpMethod = "Post",
UpdateTargetId = item.ToString(),
InsertionMode = InsertionMode.Replace,
OnSuccess = string.Format(
"disableform({0})",
Json.Encode(item)),
}))
{ <tr id = "@item">
@Html.Partial("_create",Model)
</tr>
}
} </table>
实验室测试
结果
拍摄日期
评论
@对于(int项=0;项<10;项++)
{
使用(Ajax.BeginForm(“CreateAll”、“VisitLabResult”),新的AjaxOptions
{
HttpMethod=“Post”,
UpdateTargetId=item.ToString(),
InsertionMode=InsertionMode.Replace,
OnSuccess=string.Format(
“disableform({0})”,
Json.Encode(项目)),
}))
{
@Html.Partial(“_create”,Model)
}
}
它渲染以下内容\u创建局部视图:-
@节脚本{
}
@DropDownList(“LabTestID”,String.Empty)
@Html.ValidationMessageFor(model=>model.LabTestID)
@EditorFor(model=>model.Result)
@Html.ValidationMessageFor(model=>model.Result)
@EditorFor(model=>model.datetake)
@Html.ValidationMessageFor(model=>model.datetake)
@EditorFor(model=>model.Comment)
@Html.ValidationMessageFor(model=>model.Comment)
目前,使用firefox或chrome时,所有数据注释客户端验证(如所需)都不会显示,但它们在使用IE9时可以正常工作,所以可能会出现什么问题。
BR我在这个代码块中发现了一个输入错误。在Json.Encode(item)之后添加了一个komma。如果这是最后一项,则不能添加komma
<table>
<tr>
<th>
Lab Test
</th>
<th>
Result
</th>
<th>
Date Taken
</th>
<th>
Comment
</th>
<th>
</th>
@for (int item = 0; item < 10; item++)
{
using (Ajax.BeginForm("CreateAll", "VisitLabResult", new AjaxOptions{
HttpMethod = "Post",
UpdateTargetId = item.ToString(),
InsertionMode = InsertionMode.Replace,
OnSuccess = string.Format("disableform({0})", Json.Encode(item))})
){
<tr id = "@item">
@Html.Partial("_create",Model)
</tr>
}
}
</table>
实验室测试
结果
拍摄日期
评论
@对于(int项=0;项<10;项++)
{
使用(Ajax.BeginForm(“CreateAll”、“VisitLabResult”),新的AjaxOptions{
HttpMethod=“Post”,
UpdateTargetId=item.ToString(),
InsertionMode=InsertionMode.Replace,
OnSuccess=string.Format(“disableform({0})”,Json.Encode(item))}
){
@Html.Partial(“_create”,Model)
}
}
希望这能奏效。让我知道
<table>
<tr>
<th>
Lab Test
</th>
<th>
Result
</th>
<th>
Date Taken
</th>
<th>
Comment
</th>
<th>
</th>
@for (int item = 0; item < 10; item++)
{
using (Ajax.BeginForm("CreateAll", "VisitLabResult", new AjaxOptions{
HttpMethod = "Post",
UpdateTargetId = item.ToString(),
InsertionMode = InsertionMode.Replace,
OnSuccess = string.Format("disableform({0})", Json.Encode(item))})
){
<tr id = "@item">
@Html.Partial("_create",Model)
</tr>
}
}
</table>