PartialView with a form in a window

4 posts, 1 answers
  1. Jérémy
    Jérémy avatar
    14 posts
    Member since:
    Dec 2013

    Posted 06 Feb 2015 Link to this post


    In my project, I need to put some forms in kendo windows. These forms are in other partial view. I use this to load the partial view :

    02.         .Name("editPasswordPopUp")
    03.         .Visible(false)
    04.        .Modal(true)
    05.        .Width(600)
    06.        .Height(500)
    07.       .Position(settings =>
    08.               settings.Top(70).Left(200))
    09.         .Title("Edit your password")
    10.         .Content("loading user info...")
    11.        .LoadContentFrom("EditPassword", "Member")
    12.         .Iframe(true)
    13.         .Resizable()
    14.         .Draggable()
    15.         )

    1.public ActionResult EditPassword() {
    2.    return PartialView();

    3.public ActionResult EditPassword(EditPasswordViewModel viewModel)
    5.     [....]
    6.     return RedirectToAction("Profile", "Member", new {id = viewModel.Id});
    7.     [....]

    And here is my PartialView :
    01.@using Devoteam.CustomerPortal.Application.Helpers
    02.@model Devoteam.CustomerPortal.ViewModels.EditPasswordViewModel
    04.    ViewBag.Title = "Edit";
    05.    Layout = null;
    13.@using (Html.BeginForm())
    15.    @Html.AntiForgeryToken()
    17.    <div id="messageError">
    18.        @Html.ValidationSummary()
    19.    </div>
    20.  [...] // Fields
    22.    <div class="buttons">
    23.        <input type="submit" value="Confirm" class="big-button" />
    24.        <input type="submit" value="Cancel" class="big-button" />
    25.    </div>

    When I click on the button to open the kendo window, the partial view load correctly in it.
    When I submit my form, the action is correctly called. Here is my problem : when the controller has done his job, I call a RedirectToAction to redirect the user. But the page is loaded in the kendo window instead of the main window. Is there any solution to close the kendo window ?

    Second question : how to close the kendo window when pressing the cancel button.

    Thank you.
  2. Answer
    Alexander Popov
    Alexander Popov avatar
    1436 posts

    Posted 10 Feb 2015 Link to this post

    Hello Jérémy,

    This behavior is expected, since the Window's content is displayed in an IFrame. This also prevents you from getting the Window's instance from within the Partial View and calling its close method.
    Disabling the Iframe option and not loading all JavaScript files in PartialView should solve the issue.

    Alexander Popov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Aaron
    Aaron avatar
    20 posts
    Member since:
    Jan 2015

    Posted 17 Apr 2015 Link to this post

    I am experiencing the same problem: Basically, I am allowing the (MVC C#) app user to add an option to a drop down list if it does not exist.  The Modal Window opens up for the Create action w/its respecitve "submit" button.

    In the post action, I do not WANT to redirect to the usual view if the create was from the Modal Window. I just want the Modal Window to close and the parent page to remain as-is. There is no need to refresh the parent page because the user may have entered data that would be lost on a reload. 

    So do I just close the Modal Window on the submit?

  4. Alexander Popov
    Alexander Popov avatar
    1436 posts

    Posted 21 Apr 2015 Link to this post

    Hello Aaron,

    The approach I previously suggested should be applicable in your case as well. Sharing some code snippets that we can examine though, would allow us to provide a more specific answer.

    Alexander Popov

    See What's Next in App Development. Register for TelerikNEXT.

Back to Top