2012-03-08 11 views
0

まず、私の悪い英語には申し訳ありません。 削除するユーザーをクリックしたときにページが更新されない理由を理解できません... クリック後、データベースがチェックインされ、ユーザーは削除されますが、テーブルが更新されていないページはわかりません。なぜajax.actionlinkはページを更新しないのですか?

私の見解は次のとおりです。

@model IEnumerable<SiteWebEmpty.Models.User.UserDisplay> 
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script> 
<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script> 
<script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script> 

<script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.debug.js")" type="text/javascript"></script> 
<h2>Display User</h2> 
<div id="deleteUser"> 
@using (Html.BeginForm()) 
{ 
<table class="tabledisplayUser" border="1"> 
<tr> 
<th>Name FirstName</th> 
<th>UserName</th> 
<th>Roles</th> 
<th>Choice</th> 
</tr> 
<tr> 
<th>@Html.Editor("name")</th> 
<th>@Html.Editor("username")</th> 
<th>@Html.Editor("roles")</th> 
<th>@Html.Editor("choice")</th> 
</tr> 
@foreach (var user in Model) 
{ 

    <tr> 
     <td class="action nameFirstName">@Html.DisplayFor(u => user.NameFirstName)</td>  
     <td class="action userName">@Html.DisplayFor(u => user.UserName)</td> 
     @if (user.Roles.Roles.Count.Equals(0)) 
     { 
      <td>Nobody Role</td> 
     } 
     else 
     { 
      <td>@Html.DropDownList("Roles", user.Roles.Roles)</td>  
     } 
     <td>@Html.ActionLink("Edit", "Edit", new { UserName = user.UserName }) | @Ajax.ActionLink("Delete", "Delete", new { UserName = user.UserName }, 
      new AjaxOptions() 
      { 
       HttpMethod = "POST", 
       Confirm = "Do you want delete this user?", 
       UpdateTargetId = "deleteUser" 
      })</td> 
    </tr>   
} 
</table> 
} 
</div> 

私のコントローラは、次のとおりです。

public ActionResult DisplayUser() 
    { 
     List<UserDisplay> users=getAllUserInDB(); 
     GetAllNameFirstNameLDAP(users); 
     return View(users); 
    } 

    public ActionResult Delete(String userName) 
    { 
     DeleteDB(userName); 
     if (!Request.IsAjaxRequest()) 
      return RedirectToAction("DisplayUser"); 
     else 
     { 
      List<UserDisplay> users = getAllUserInDB(); 
      GetAllNameFirstNameLDAP(users); 
      return PartialView("DisplayUser",users); 
     } 
    } 

それは働いていない理由を私は理解していない、あなたの助けをありがとう!

+0

それは仕事です!助けてくれてありがとう – Zoners

答えて

1

UpdateTargetId = "deleteUser"は、id="deleteUser"でDOM要素をリフレッシュすることを意味します。そのような要素はありません。

あなたは持っている:だからidを持つクラスを交換し、あなたのテーブルには、通常、リフレッシュする必要があり

<div id="deleteUser"> 

<div class="deleteUser"> 

と同じではありませんています。

関連する問題