Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:47:28+00:00 2026-06-07T03:47:28+00:00

I don’t know how to stay in the same page after changing the password

  • 0

I don’t know how to stay in the same page after changing the password inside a partial view. When i click the “Submit” button it takes me to another page, I would like to stay in the same page and only show a message like “password changing success” I Know the key is in

if (changePasswordSucceeded)
            {
                return RedirectToAction("ChangePasswordSuccess");


            }

I’ve tried with

return Json(true)

but i don’t know how to handle the result for just updating the page.

Thank you

UPDATE:
MAIN VIEW

@model Points2Pay.Models.Usuario
@using Points2Pay.Extensions;

@{
    ViewBag.Title = @Resources.Points2pay.Usuario_Tools2;
    ViewBag.Head = @Resources.Points2pay.Usuario_Tools2;
}

<h2>@Resources.Points2pay.Usuario_Head4</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>@Resources.Points2pay.Account_Text5</legend>

        @Html.HiddenFor(model => model.UsuarioId)
        @Html.HiddenFor(model => model.EmailAlterno)

        <div class="editor-label">
            @Html.LabelFor(model => model.Nombre) @Html.RequiredFieldFor(model => model.Nombre)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Nombre)
            @Html.ValidationMessageFor(model => model.Nombre)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Apellidos) @Html.RequiredFieldFor(model => model.Apellidos)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Apellidos)
            @Html.ValidationMessageFor(model => model.Apellidos)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Direccion) @Html.RequiredFieldFor(model => model.Direccion)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Direccion)
            @Html.ValidationMessageFor(model => model.Direccion)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Pais) @Html.RequiredFieldFor(model => model.Pais)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Pais)
            @Html.ValidationMessageFor(model => model.Pais)
        </div>

        @*<div class="editor-label">
            @Html.LabelFor(model => model.EmailAlterno)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EmailAlterno)
            @Html.ValidationMessageFor(model => model.EmailAlterno)
        </div>*@

        <div class="editor-label">
            @Html.LabelFor(model => model.Telefono) @Html.RequiredFieldFor(model => model.Telefono)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Telefono)
            @Html.ValidationMessageFor(model => model.Telefono)
        </div>

@*        <div class="editor-label">
            @Html.LabelFor(model => model.FechaAlta)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FechaAlta)
            @Html.ValidationMessageFor(model => model.FechaAlta)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Estatus)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Estatus)
            @Html.ValidationMessageFor(model => model.Estatus)
        </div>*@

@*        <div class="editor-label">
            @Html.LabelFor(model => model.Saldopublic)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Saldopublic)
            @Html.ValidationMessageFor(model => model.Saldopublic)
        </div>*@

@*        <br />
           @Html.ActionLink(@Resources.Points2pay.ChangePassword, "ChangePassword", "Account", new { id = Model.UsuarioId }, null)
           <br />*@
        <p>
            <input type="submit" value="@Resources.Points2pay.btn_Guardar" />
        </p>
    </fieldset> @Resources.Points2pay.CamposObligatorios <br />
}

<input type="submit" class="flip" value="@Resources.Points2pay.ChangePassword" />
<div class="panel">
@Html.Action("ChangePasswordPartial","Account")
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $(".panel").hide();
        $(".flip").click(function () {
            $(".panel").slideToggle("slow");
        });
    });
</script>

PARTIAL VIEW

@model Points2Pay.Models.ChangePasswordModel

@{
    ViewBag.Title = Resources.Points2pay.ChangePassword;
    ViewBag.Head = Resources.Points2pay.ChangePassword;
}

<h2>@Resources.Points2pay.Account_Head1</h2>
<p>
    @Resources.Points2pay.Account_Text1 
</p>
<p>
    @Resources.Points2pay.Account_Text2 @Membership.MinRequiredPasswordLength @Resources.Points2pay.Account_Text3
</p>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true, @Resources.Points2pay.Account_Text4)
    <div>
        <fieldset>
            <legend>@Resources.Points2pay.Account_Text5</legend>

            <div class="editor-label">
                @Html.LabelFor(m => m.OldPassword)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.OldPassword)
                @Html.ValidationMessageFor(m => m.OldPassword)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.NewPassword)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.NewPassword)
                @Html.ValidationMessageFor(m => m.NewPassword)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.ConfirmPassword)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.ConfirmPassword)
                @Html.ValidationMessageFor(m => m.ConfirmPassword)
            </div>

            <p>
                <input type="submit" value="@Resources.Points2pay.ChangePassword_Boton1" />
            </p>
        </fieldset>
    </div>
}
<script>
    $(document).ready(function () {
        $('form').submit(function (e) {
            $.ajax({
                url: $(this).action,
                type: 'POST', //I'm assuming this could be type GET.
                data: $(this).serialize,
                dataType: 'json',
                success: function (data) {
                    alert('ajax successfully');
                }
            });
            e.preventDefault();
        });
    });
</script>

CONTROLLER

[Authorize]
        [HttpPost]
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {

                // ChangePassword will throw an exception rather
                // than return false in certain failure scenarios.
                bool changePasswordSucceeded;
                try
                {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    //return RedirectToAction("ChangePasswordSuccess");
                    return Json(true);


                }
                else
                {
                    ModelState.AddModelError("", Resources.Points2pay.Account_Error22);
                    //
                    //English
                    //ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:47:29+00:00Added an answer on June 7, 2026 at 3:47 am
    <div id="ShowResultHere"></div>
    
    @using (Html.BeginForm("Update", "Test", FormMethod.Post, new { id="frmUpdate"}))
    {
       //form fields
       <button type="submit" class="sprt bg_red bt_red h27">Update</button>
    }
    
    [HttpPost]
    public ActionResult Update(TestModel model)
    {
       return Json(new { s = "Success" });
    }
    
    $(function() {
        $('#frmUpdate').submit(function() {
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function(result) {
                   // The AJAX call succeeded and the server returned a JSON 
                   // with a property "s" => we can use this property
                   // and set the html of the target div
                   $('#ShowResultHere').html(result.s);
                }
            });
            // it is important to return false in order to 
            // cancel the default submission of the form
            // and perform the AJAX call
            return false;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know if this question is trivial or not. But after a couple
Don't know why this is happening, but after submitting a form via JS (using
Don't know why, but sometimes LocationManager is still working also after closing application. I
Don't know much about encryption... Say I'm preparing a SAML request to submit to
Don't really know how to formulate the title, but it should be pretty obvious
Don't know how to google for such, but is there a way to query
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
I don't know whether this is really possible, but I'm trying my best. If
I don't know if this is a well known 'thing' or something new in
I don't want to know a way to preload images, I found much on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.