1

私はMVCに不慣れです。ポップアップMVC3かみそりでデータを編集する方法。私はたくさんゴーグルしましたが、それを取得できませんでした。私はjqueryを使用しています。私のコントローラー-

[HttpGet]
    public ActionResult Edit(int id)
    {

        var q = from p in db.accs
                where p.id == id
                select p;
        return View(q.FirstOrDefault());
    }
    [HttpPost]
    public ActionResult Edit(int id,account ac)
    {
        acc a = (from p in db.accs
                     where p.id==id
                     select p).Single();

        if (ModelState.IsValid)
        {
            a.f_name = ac.f_name;
            a.l_name = ac.l_name;
            a.Address = ac.Address;
            a.Phoneno = ac.Phoneno;
            db.SubmitChanges();
            int i = 2;
            return RedirectToAction("Display", new { i = i });
        }
        else
        {
            return View("Edit");
        }
4

2 に答える 2

2

それを実現できるjQueryUIダイアログコンポーネントをご覧ください

于 2012-06-28T08:06:05.217 に答える
1

部分ビューを返すことができる Ajax.ActionLink を使用する必要があり、その結果が div に追加され、OnSuccess でその部分ビューが表示されます。


 @Ajax.ActionLink("popup", "SomeAction", new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result",     InsertionMode = InsertionMode.Replace, OnSuccess="openPopup" })<br />

   <div id="result" style="display:none;"></div>

   <script type="text/javascript">
       $(document).ready(function() {
          $("#result").dialog({
             autoOpen: false,
               title: 'Title',
              width: 500,
             height: 'auto',
            modal: true
        });
   });
       function openPopup() {
         $("#result").dialog("open");
}

于 2012-06-28T08:15:01.337 に答える