c# - Close KendoUI Window & reload Parent page on successful login -
i have view contains "button" & kendoui window not visible default.
index.cshtml:
@(html.kendo().button() .name("btnlogin") .content("login") .events(e => e.click("loginbtn"))) @{html.kendo().window() .name("windowlogin") .title("login") .content("loading user info...") .loadcontentfrom("login", "account") .modal(true) .visible(false) .iframe(true) .draggable() .resizable() .render(); }
on click of button, modal window opened contains form. "login" action reurning view containing complete form.
login.cshtml:
<h2>login details</h2> @html.validationmessage("error") @using (html.beginform("login", "account", formmethod.post)) { <table> <tr> <td> @html.label("username: ") </td> </td> <td> @html.textboxfor(user => user.username) </td> <td> @html.validationmessagefor(user => user.username, "enter name") </td> </tr> <tr></tr> <tr> <td> @html.label("password: ") </td> <td> @html.passwordfor(user => user.password) </td> <td> @html.validationmessagefor(user => user.password, "enter password") </td> </tr> <tr></tr> <tr> <td> <input type="submit" value="login" /> </td> <td> <input id="cancelbutton" type="button" value="cancel" /> </td> </tr> </table> } @section scripts { @scripts.render("~/bundles/jqueryval") }
accountcontroller.cs:
[httppost] public actionresult login(user user) { var userdetails = executequeries.getuser(user); if (userdetails != null) { session["username"] = userdetails.username; //formsauthentication.redirectfromloginpage(user.username, true); } else { modelstate.addmodelerror("error", "username or password incorrect"); } return view("login"); }
the problem facing not able close modal window & reload parent screen. after successful login new window opening in same modal window, want close modal window & refresh parent screen.
it's simple calling window.close(). script inside " kendo windowed" view. on successful login before return view set propoerty on model true or something. model.closewindow = true;
, put code in view engine
@if (model.closewindow == true) { <script> // close popup var w = window.parent.$("#createmanualproposalwindow").data("kendowindow"); w.close(); </script> }
here's how window defined.
@(html.kendo().window() .name("createmanualproposalwindow") .title("manual proposal details") .draggable(true) .resizable() .scrollable(false) .width(880) .height(650) .visible(false) .iframe(true) .modal(true) .events(e => e .close("manualwindow_close")) )
you'll see close event, inside event can handle refreshing of parent page.
function manualwindow_close() { var agggrid = $("#agg_grid").data("kendogrid"); agggrid.datasource.read(); var grid = $("#grid").data("kendogrid"); grid.datasource.page(1); refreshgetcontracttotals(); }
Comments
Post a Comment