How to call script based on Data from Model.

2 posts, 1 answers
  1. Answer
    Greg Gum
    Greg Gum avatar
    18 posts
    Member since:
    Jun 2009

    Posted 12 Dec 2013 Link to this post

    I have the following code.  In the model is a property called IsAuthenticated.  After the ajax refresh, I need to check this property, and if true, then close the Window.  What is the best way to do this?

     

    @using (Ajax.BeginForm("Login", "Account", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "loginSection", }))
            {
                @Html.Partial("_LoginInfoPartial", Model)
                <input} type="submit" value="Log in" />
                <button type="button"  id="close_button" onclick="cancelLogin()" >Cancel</button>
                 
                <script>
                    function cancelLogin()
                    {
                        var window = $("#loginWindow").data("kendoWindow");
                        window.close();
                    }
                </script>
             }

     

     

     

     

  2. Greg Gum
    Greg Gum avatar
    18 posts
    Member since:
    Jun 2009

    Posted 13 Dec 2013 Link to this post

    This worked for me to close the window.
    Controller:

        return PartialView("_LoginSuccessPartial");

    View:

        <script>
        var loginwindow = $("#loginWindow").data("kendoWindow");
        loginwindow.close();
       </script>
  3. Kendo UI is VS 2017 Ready
Back to Top