ASP.NET MVC partial view does not call my Action
Posted
by Johannes
on Stack Overflow
See other posts from Stack Overflow
or by Johannes
Published on 2010-03-08T19:00:55Z
Indexed on
2010/03/08
19:06 UTC
Read the original article
Hit count: 514
asp.net-mvc
I just started building a small simple Website on ASP.NET MVC, in a page I am using a Partial view, the Partial View represents a simple Form which should be submitted on button click, and If I click the first Time it is submitted with success and does return my partial view with my validation Messages (if the content is invalid) but if I wish to try again the Action isn't called again. Any Idea?
View:
<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;
});
});
/*$(document).ready(function() {
$('#jform').live('submit', function() {
$.post($(this).attr('action'), $(this).serialize(), function(data) {
$("#jform").replaceWith($(data));
});
return false;
});
});*/
</script>
Part of the Controller:
if (!ValidateChangePassword(currentPassword, newPassword, confirmPassword))
{
return PartialView(ViewData);
}
© Stack Overflow or respective owner