It's not clear to me how to handle an MVC form update in the Window and have the results returned to the and not the supporting page.
In my MVC2 application, one of of the views I want a modal window to update some related data. So on the view I declare my window like this:
<% Html.Telerik().Window() .Name("Window") .Title("Title of New Window") .Draggable(true) .Modal(true) .Buttons(b => b.Close()) .LoadContentFrom("/Controller/Action") .Width(400) .Height(105) .Visible(false) .Render(); %>
Thus I have a window ready to be opened. When the user clicks on a button on a row of a grid on the view, I open the window using this code
<div class="t-grid-action t-button t-state-default" onclick="openWindow( '<%: ViewData["Property1"] %>', '<%: Model.Property2 %>');"> Add </div> The js function is pretty simple too:
function openWindow(parm1, parm2) { var window = $("#Window").data("tWindow"); var url = "/Controller/Action2?parm1=" + parm1 + "&parm2=" + parm2; window.ajaxRequest(url); window.center(); window.open(); }Action2 is HttpGet and returns a view based on a strongly typed model. So far, so good. Now, when the view *posts* back to the controller
<% using (Html.BeginForm("Action2", "Controller", RouteObject, FormMethod.Post)) {%>And in the controller Action2 has a different method for HttpPost, which updates the model, etc. However when I return the view instead of just the Window being updated and staying modal (so the user can correct the form), what happens instead is that the entire browser window is updated, not the modal window.
What am I doing wrong? I'd expect just the modal would be updated, not the entire browser.