after return PartialView() Url.Actionlink("Action", "Controller"), the Controller is lost
- by Johannes
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);
}