This is a migrated thread and some comments may be shown as answers.

PartialView with a form in a window

3 Answers 799 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jérémy
Top achievements
Rank 1
Jérémy asked on 06 Feb 2015, 08:36 AM
Hi,

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 :

01.@(Html.Kendo().Window()
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.}

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

And here is my PartialView :
01.@using Devoteam.CustomerPortal.Application.Helpers
02.@model Devoteam.CustomerPortal.ViewModels.EditPasswordViewModel
03.@{
04.    ViewBag.Title = "Edit";
05.    Layout = null;
06.}
07. 
08.@Styles.Render("~/Content/css")
09.@Scripts.Render("~/bundles/jquery")
10.@Scripts.Render("~/bundles/jqueryval")
11.@Scripts.Render("~/bundles/kendo")
12. 
13.@using (Html.BeginForm())
14.{
15.    @Html.AntiForgeryToken()
16. 
17.    <div id="messageError">
18.        @Html.ValidationSummary()
19.    </div>
20.  [...] // Fields
21.     
22.    <div class="buttons">
23.        <input type="submit" value="Confirm" class="big-button" />
24.        <input type="submit" value="Cancel" class="big-button" />
25.    </div>
26.}


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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 10 Feb 2015, 07:27 AM
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.

Regards,
Alexander Popov
Telerik
 

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.

 
0
Aaron
Top achievements
Rank 1
answered on 17 Apr 2015, 03:23 PM

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?

0
Alexander Popov
Telerik team
answered on 21 Apr 2015, 09:41 AM
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.

Regards,
Alexander Popov
Telerik
 

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

 
Tags
Window
Asked by
Jérémy
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Aaron
Top achievements
Rank 1
Share this question
or