Witam,
chciałbym dodać do jednego z widoków komponent Bootstrap Modal. Okienko to ma podawać dane z PartialView ("_Details"). Wszystko jest OK, ale jak wybiorę już szczegóły dla jednej osoby to po zamknięciu okienka Modal i wejściu w inną osobę pojawiają mi się w dalszym ciągu informacje o osobie wybranej pierwotnie. Poniżej przedstawiam fragmenty kodu. Proszę o pomoc w jaki sposób mogę zrobić tak aby po zamknięciu okna Modal i wybraniu ponownie dla innego UserID dane były wyświetlane prawidłowo a nie zapaamiętane dla pierwszego wybranego użytkownika.
Widok Index - wywołujący okno szczegółów
@model IEnumerable<Repository.Models.User>
@{
ViewBag.Title = "Index";
}
<h2>Użytkownicy</h2>
<br />
<table class="table user-table table-condensed table-striped">
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Surname)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Surname)
</td>
<td>
@Html.ActionLink("Edytuj", "Edit", new { id=item.UserID }, new {@class="btn user-btn btn-success"})
@Html.ActionLink("Szczegóły", "Details", "Users", new { id = item.UserID }, new { @class = "btn user-btn btn-primary", data_toggle="modal", data_target="#myModal" })
@Html.ActionLink("Usuń", "Delete", new { id = item.UserID }, new { @class = "btn user-btn btn-danger" })
</td>
</tr>
}
</table>
Kontroler UsersController
public ActionResult Details(int? id)
{
if (id==null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
User user = db.Users.Find(id);
if (user==null)
{
return HttpNotFound();
}
return PartialView("_Details", user);
}
Widok _Details
@model Repository.Models.User
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">@Html.DisplayFor(model => model.Name) @Html.DisplayFor(model => model.Surname)</h4>
</div>
<div class="modal-body">
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Name)
</dt>
<dd>
@Html.DisplayFor(model => model.Name)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Surname)
</dt>
<dd>
@Html.DisplayFor(model => model.Surname)
</dd>
</dl>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>