How to redirect to another popup on ASP.NET MVC

1.2k views Asked by At

My existing ASP.NET webforms project has a product page, which features a "Review" link. Upon clicking this link, it opens a modal popup where you can select rating, and enter comments etc. Upon clicking submit it submits the form if the user is logged in. If the user is not logged in, it closes the "Review" modal and opens "Login" modal. Once the user enters login information, it saves the review comments already entered in earlier modal popup.

I am converting the application to MVC 5. I can open the review modal popup correctly and save the values if user is logged in (through Ajax.Beginform). But if the user is not logged in, how do I close the review modal and open the login modal? RedirectToPermanent action only causes to the Ajax OnFailure code to run.

1

There are 1 answers

0
Chih-Ho Andy Chou On BEST ANSWER

You can do it with partial views; create 2 partial views - one for review and the other for login; and you will have a modal box to hold a partial view based on if user is logged in:

<div id="ModalBox">
@{
    if (Request.IsAuthenticated)
        Html.RenderPartial("_ReviewPartial");
    else
        Html.RenderPartial("_LoginPartial");
}
</div>   

Then you use jQuery to bind onclick event to open ModalBox.