after return PartialView() Url.Actionlink("Action", "Controller"), the Controller is lost

Posted by Johannes on Stack Overflow See other posts from Stack Overflow or by Johannes
Published on 2010-03-09T22:01:59Z Indexed on 2010/03/12 3:37 UTC
Read the original article Hit count: 965

Filed under:

Well the Question is related to a problem I posted before (http://stackoverflow.com/questions/2403899/asp-net-mvc-partial-view-does-not-call-my-action). In practice I've a partial view which contains a Form, after submitting the Form the Controller returns the Partial View.

Well the Problem is if I reload the page which contains the partial view the function <%= Url.Action("ChangePassword", "Account") %> returns "Account/ChangePassword", if I submit the form and the partial is returned by the controller.

Using return PartialView() the function <%= Url.Action("ChangePassword", "Account") %> returns only "ChangePassword".

Any Idea because?

The View looks like:

<form action="<%= Url.Action("ChangePassword", "Account") %>" method="post" id="jform"> 
    <div> 
        <fieldset> 
            <legend>Account Information</legend> 
            <p> 
                <label for="currentPassword">Current password:</label> 
                <%= Html.Password("currentPassword") %> 
                <%= Html.ValidationMessage("currentPassword") %> 
            </p> 
            <p> 
                <label for="newPassword">New password:</label> 
                <%= Html.Password("newPassword") %> 
                <%= Html.ValidationMessage("newPassword") %> 
            </p> 
            <p> 
                <label for="confirmPassword">Confirm new password:</label> 
                <%= Html.Password("confirmPassword") %> 
                <%= Html.ValidationMessage("confirmPassword") %> 
            </p> 
            <p> 
                <input type="submit" value="Change Password" /> 
            </p> 
        </fieldset> 
    </div> 
</form> 
</div> 

<script> 
    $(function() { 
        $('#jform').submit(function() { 
            $('#jform').ajaxSubmit({ target: '#FmChangePassword' }); return false; 
        }); 
    }); 
</script> 

Part of the Controller:

    if (!ValidateChangePassword(currentPassword, newPassword, confirmPassword)) 
    { 
        return PartialView(ViewData);                 
    } 

© Stack Overflow or respective owner

Related posts about asp.net-mvc