ASP.NET MVC は、この種のニーズに最適なフレームワークです。もし私があなたの立場にいたら、JQuery Ajax API を使って作業したいと思います。
次のブログ投稿は、サーバーへの PartialViews、JQuery、および Ajax 呼び出しで何ができるかについてのヒントを提供するはずです。
http://www.tugberkugurlu.com/archive/working-with-jquery-ajax-api-on-asp-net-mvc-3-0-power-of-json-jquery-and-asp-net-mvc-部分ビュー
アップデート
簡単な紹介を入れるように頼まれたので、ここにあります。
次のコードはアクション メソッドです。
[HttpPost]
public ActionResult toogleIsDone(int itemId) {
//Getting the item according to itemId param
var model = _entities.ToDoTBs.FirstOrDefault(x => x.ToDoItemID == itemId);
//toggling the IsDone property
model.IsDone = !model.IsDone;
//Making the change on the db and saving
ObjectStateEntry osmEntry = _entities.ObjectStateManager.GetObjectStateEntry(model);
osmEntry.ChangeState(EntityState.Modified);
_entities.SaveChanges();
var updatedModel = _entities.ToDoTBs;
//returning the new template as json result
return Json(new { data = this.RenderPartialViewToString("_ToDoDBListPartial", updatedModel) });
}
RenderPartialViewToString はコントローラーの拡張メソッドです。ここで Nuget を使用して、TugberkUg.MVC という非常に小さなパッケージをダウンさせる必要があります。このパッケージ
には、コントローラー内で部分ビューを文字列に変換するためのコントローラー拡張機能があります。
次に、 JQuery で呼び出す方法に関する簡単な情報を次に示します。
var itemId = element.attr("data-tododb-itemid");
var d = "itemId=" + itemId;
var actionURL = '@Url.Action("toogleIsDone", "ToDo")';
$("#ajax-progress-dialog").dialog("open");
$.ajax({
type: "POST",
url: actionURL,
data: d,
success: function (r) {
$("#to-do-db-list-container").html(r.data);
},
complete: function () {
$("#ajax-progress-dialog").dialog("close");
$(".isDone").bind("click", function (event) {
toggleIsDone(event, $(this));
});
},
error: function (req, status, error) {
//do what you need to do here if an error occurs
$("#ajax-progress-dialog").dialog("close");
}
});
いくつかの追加の手順を実行する必要があります。完全なウォークスルーを含むブログ投稿を見てください。