1

I am using the MVC Ajax.BeginForm("LogOn", "Account", new AjaxOptions { UpdateTargetId="updateajax" }) <div id=updateajax/> so it only updates to that area. The login form is the ajax.beginform. But can you cancel the AjaxRequest inside the controller. What I wanted is that when I am loggin in the ajax, it will only update the validations but when the login is successful I want the whole page to redirect or update again. In my controller I return the entire page when the login is successful but that put the whole content inside the updateajax div. What can I do to solve this problem? I just want to stop the ajax call when the login is successful.

1 Answer 1

2

You sort of have to either redirect or update the whole body of the page. Or you can wrap the whole body content in a div and ajax update that one. My suggestion is to go ahead and redirect, because if you have scripts that run on load, you would have to manually call them.

    <body>
     <div id="ajaxUpdatedPanel">
        <% using (Ajax.BeginForm("LogOn", "Account", new AjaxOptions { 
                      UpdateTargetId="ajaxUpdatedPanel", 
                      OnSuccess = "redirectTo" }) { %>
        ....
        ....
        <script type="text/javascript">
           function redirectTo() {
                window.location = "your_redirect_url";
             }
        </script>
     <div>
    </body>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.