部分视图上的ActionResult更改主视图

时间:2013-08-29 10:04:09

标签: jquery asp.net-mvc kendo-ui

我有一个页面打开一个kendo ui Window来显示部分视图中包含的数据...我在这个局部视图中有一个按钮,可以在DB上执行保存...当Action完成时我得到主页面重定向到我在模态中的视图...我该如何解决这个问题?不应该那个视图/控制器只存在于我打开的弹出窗口中吗?

Condider此主页面显示了具有网格的用户列表。 我点击了一个按钮,我打开了这个

var mywindow = $("#window");

        mywindow.kendoWindow({
            width: "615px",
            title: "Cambio Password",
            content: "CambioPassword",
            modal : true
        });
        mywindow.data("kendoWindow").open();

我的CambioPasswordController是

[Authorize]
public class CambioPasswordController : BaseController
{
    private readonly IAdminRepository adminRepository;

    public CambioPasswordController(IAdminRepository adminRepository)
    {
        this.adminRepository = adminRepository;
    }

    public ActionResult Index()
    {
        CambioPasswordModel cambioPasswordModel = new CambioPasswordModel();

        if (this.Request.Params.Count > 0 && (this.Request.Params)["IdUser"] != null)
            cambioPasswordModel.IdUser = Convert.ToInt32((this.Request.Params)["IdUser"]);

        return PartialView(cambioPasswordModel);
    }

    [HttpPost]
    public ActionResult CambioPassword(CambioPasswordModel newPwd)
    {
        if (ModelState.IsValid)
        {

            var user = SessionHelper.GetObjectFromSession<Utente>(this.Session, "user");

            var result = adminRepository.CambioPassword(newPwd.IdUser.ToString(), newPwd.Password, user.IDInterno);

            if (!string.IsNullOrEmpty(result.Message))
            {
                TempData["message"] = result.Message;
            }
            else
            {
                TempData["message"] = "Password cambiata con successo";
                //chiudi la finestra
            }
        }
        else
        {
            ModelState.AddModelError("", "Errore cambio password");
        }
        return PartialView("Index"); // <<<------ THIS LEADS THE MAIN PAGE TO go to /CambioPassword/Index
    }

我做错了什么? 谢谢     }

0 个答案:

没有答案
相关问题