views:

49

answers:

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  A: 

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>
Tomislav Markovski
thank you for the answer
Ganator