I have a screen that does the user's password change. This screen shows the user name and clicking the name, it is directed to the screen to change the password.
As I would do to make this call with a modal, I already have the scripts, but I can not use it with Html.ActionLink
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "ChangePassword", "Manage" ))
}
}
<script type="text/javascript">
$(function () {
$.ajaxSetup({ cache: false });
$("a[data-modal]").on("click", function (e) {
$('#myModalContent1').load(this.href, function () {
$('#myModalLogin').modal({
/*backdrop: 'static',*/
keyboard: true
}, 'show');
bindForm(this);
});
return false;
});
});
function bindForm(dialog) {
$('form', dialog).submit(function () {
$.ajax({
url: this.action,
type: this.method,
data: $(this).serialize(),
success: function (result) {
if (result.success) {
$('#myModalLogin').modal('hide');
$('#replacetarget').load(result.url); // Carrega o resultado HTML para a div demarcada
} else {
$('#myModalContent1').html(result);
bindForm(dialog);
}
}
});
return false;
});
}
</script>
<div id="myModalLogin" class="modal fade in">
<div class="modal-dialog">
<div class="modal-content">
<div id="myModalContent1"></div>
</div>
</div>
</div>