This question is locked. New answers and comments are not allowed.
Hey,
So, what I'm trying to do - is load the window using content being loaded via the client side, like this (this is from the main view, where the window is located, and the client script that opens it):
And I have my form view, which looks like this:
Here's the controller for the form:
But what's happening, is that if I follow the code on the sample - the page redirects to the form view which isn't what I would be expecting. On the sample, the modal window closes and the information entered into the form appears on the page. So, what's wrong here? Why doesn't this work?
-- Kori
So, what I'm trying to do - is load the window using content being loaded via the client side, like this (this is from the main view, where the window is located, and the client script that opens it):
<button id='FormButton'>Open Form</button>@(Html.Telerik().Window() .Name("Window") .Modal(true) .Resizable(resize => resize.Enabled(true)) .Buttons(buttons => buttons.Refresh().Maximize().Close()) .Draggable(true) .Visible(false) .Effects(effects => effects.Toggle().Opacity()) )@if ((!string.IsNullOrEmpty(ViewBag.FirstName)) || (!string.IsNullOrEmpty(ViewBag.LastName))){ <div> You Entered: <table> <tr> <td>First Name:</td> <td>@ViewBag.FirstName</td> </tr> <tr> <td>Last Name:</td> <td>@ViewBag.LastName</td> </tr> </table> </div>}<script type="text/javascript"> function PageLoad() { $("#FormButton").click(function (e) { OpenWindow("/TestApp/Window/FormTest"); }); $('t-button').live('mouseenter', $.telerik.buttonHover) .live('mouseleave', $.telerik.buttonLeave); } function OpenWindow(path) { var wnd = $('#Window').data('tWindow'); if (wnd != null) { wnd.ajaxRequest(path); wnd.center().open(); } } function CloseWindow() { var wnd = $('#Window').data('tWindow'); if (wnd != null) { wnd.close(); } }</script>And I have my form view, which looks like this:
@using (Html.BeginForm("FormTest", "Window", FormMethod.Post, new { id = "feedback-form" })){ <fieldset> <legend>FormTestViewModel</legend> <div class="editor-label"> @Html.LabelFor(model => model.FirstName) </div> <div class="editor-field"> @Html.EditorFor(model => model.FirstName) </div> <div class="editor-label"> @Html.LabelFor(model => model.LastName) </div> <div class="editor-field"> @Html.EditorFor(model => model.LastName) </div> <p> <button type="submit" class="t-button">Create</button> <button type="button" class="t-button">Close</button> </p> </fieldset>}Here's the controller for the form:
public partial class WindowController : Controller { public ActionResult FormTest() { return View(); } [HttpPost] public ActionResult FormTest(FormTestViewModel model) { if (ModelState.IsValid) { ViewBag.FirstName = model.FirstName; ViewBag.LastName = model.LastName; } return View(); } }But what's happening, is that if I follow the code on the sample - the page redirects to the form view which isn't what I would be expecting. On the sample, the modal window closes and the information entered into the form appears on the page. So, what's wrong here? Why doesn't this work?
-- Kori