2012-05-02 5 views
3

に動作していない私は私のasp.net MVC Webアプリケーション内の以下のメインビューを持っている: -クライアント側のデータ注釈検証は部分的にFirefoxを使用してビューとクロム

<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> 

次_CREATE部分ビューをレンダリングします: - @sectionスクリプト{

}

<td> 
     @Html.DropDownList("LabTestID", String.Empty) 
     @Html.ValidationMessageFor(model => model.LabTestID) 
    </td> 
    <td> 
     @Html.EditorFor(model => model.Result) 
     @Html.ValidationMessageFor(model => model.Result) 
    </td> 
    <td> 
     @Html.EditorFor(model => model.DateTaken) 
     @Html.ValidationMessageFor(model => model.DateTaken) 
    </td> 
    <td> 
     @Html.EditorFor(model => model.Comment) 
     @Html.ValidationMessageFor(model => model.Comment) 

    </td> 
    <td> 
    <input type= "hidden" name = "visitid" value = "@ViewBag.visitid" /> 
    <input type="submit" value="Create" /> 
    </td> 

現在、必須のようなすべてのデータアノテーションクライアント側の検証では、firefoxやchromeを使用していると表示されませんが、IE9を使用すると正しく動作します。 BR

答えて

0

このコードブロックにタイプミスがあります。あなたは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> 

これがうまくいきます。お知らせ下さい。

関連する問題