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 7429241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:56:17+00:00 2026-05-29T08:56:17+00:00

I am having a problem of a partial page update on Asp.net mvc 3

  • 0

I am having a problem of a partial page update on Asp.net mvc 3 razor that I cannot get through

I have this _LogOn partial view which has 2 text boxes Email and Password and a button connexion for login purpose:

@using (Html.BeginForm())
{

    @Html.ValidationSummary(true)

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

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

    <p>
        <input id="submitConnexion" type="submit" value="Connexion" />
        <a id="lnForgetPwd"> Mot de passe oublié</a>
    </p>
}

And here is the controllers: the GET controller does not nothing more than grabbing the _Logon partialV view and hand it to jquery to update a div called Div-2.

    // GET: Account/Logon 
    public ActionResult LogOn()
    {
        return PartialView("_LogOn");
    }

The POST controller is supposed to check that the password is correct, if so it return to Json value of true if login/password is ok, otherwhise refresh the Div-2 with errors.

    // POST: Account/Logon
    [HttpPost]
    public ActionResult LogOn(UserLogon model)
    {
        bool result = false;

        if (ModelState.IsValid)
        {
            UserManager userManager = new UserManager();
            string password = userManager.GetUserPassword(model.Email);

            if (string.IsNullOrEmpty(password))
            {

                ModelState.AddModelError("", "Mot de passe ou email incorrect.");
                result = false;
            }

            if (model.Password == password)
            {
                FormsAuthentication.SetAuthCookie(model.Email, false);
                result = true;
            }
        }

        //return Json(new { JsResult = result });

        return PartialView("_Logon", model);

    }

And here is finally the Ajax Jquery code

    // Ajax call POST for login form button submitConnexion
    $("#submitConnexion").live('click', function () {

        var email = $("#div-2 #Email").val();
        var password = $("#div-2 #Password").val();

        var data = { Email: "hello", Password: password };

        alert(email + password);

        $.ajax({

                url: "/Account/LogOn",
                type: "POST",
                //data: JSON.stringify(data),
                //contentType: 'application/json; charset=utf-8',

                success: function (result) {

                    alert("Hello");
                    $("#div-2").empty();
                    $("#div-2").html(result).hide().fadeIn(300);
                }
        });

    });
    // Ajax call POST for login form button

It is not working 2 problems

  1. everytime that I click on the ‘Connexion’ button, The post controller is fired (I supposed from the @html.Beginform of the _Logon Partial View) and not from the Ajax Jquery

As a result, the partialView is displayed on a new internet page instead of displaying within the Div-2

  1. I want to update the Div-2 with a return partial view in case of the login/password check failure, but how can I tell the action controller to send me back a result in Json for ajax Jquery if login/password ok instead of a partial view ?

Thank you

  • 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-05-29T08:56:18+00:00Added an answer on May 29, 2026 at 8:56 am

    Ok one Question at a time

    1. use '@Url.Action("ActionMethodName", "ControllerName")' in url: field, the one done by you is not accurate.
    2. coming to second question thats simple just use dataType: "json" in your ajax code block after data: , that makes sure you can return json as result instead of partial view
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With ASP.NET MVC3 (Razor) I have a simple page that loads a jQuery UI
I am having a problem with Jquery Tabs. On my MVC page, I have
We are having problem with the server migration. We have one application that are
I'm having a problem and I cannot understand why. I have a GridView and
I am having that problem that I am getting the wrong partial rendered. Instead
im having a problem in my ASP .NET calculator project. I'm using VB10, all
I'm having problem when running my Windows Forms program. In the program, I have
I'm having problem with Rails plugin attachment_fu . On every upload, I get validation
I'm having problem selecting an element with an id like this <li =0f:Bactidol_Recorder.mp4>. I
I need to be notified any time a largeish asp.net mvc web application makes

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.