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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:51:54+00:00 2026-05-22T00:51:54+00:00

I am using Visual Studio 2010 updated to the latest version and the MVC3

  • 0

I am using Visual Studio 2010 updated to the latest version and the MVC3 framework updated to the latest version. I am also using jquery 1.5.1 but this issue does not appear to be jquery related.

I have the following main page:

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css"  type="text/css" />
<link href="@Url.Content("~/Content/UserMaintainance.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/UserMaintainance.js")" type="text/javascript"></script>

@model TourSystem2.Models.UserMaintainanceViewModel
@{
    ViewBag.Title = "UserMaintainance";
}

@Model.Debug

<h2>User Maintainance</h2>
<div id = "EditUser"></div>
<table>
<tr id="1">
    <td><button type="button"  class = "deleteButton"></button></td>

    <td><button type="button"  class = "editButton"></button></td>
    <td>John                          </td>
    <td>john                          </td>
    <td>A</td>
    <td>1234                </td>
    <td></td>

    //snipped some unrelated form generation of user information showing
    <tr id = "0">
    <td colspan = "7"><button type = "button" id = "addButton">Add New User</button></td>
    </tr>
</table>

In the java script for this form, I do the following for the addButton:

$(function () {
$(':button.editButton, :button#addButton').click(function () {
    var myData = $(this).parent().parent().attr("id");
    $.post("/Admin/EditUser", { UserID: myData },
        function (data) {
            $('#EditUser').html(data);
            $('#EditUser').dialog({
                modal: true,
                width: 400,
                resizable: false,
                buttons: {
                    "Save": function () {
                        $(this).dialog("close");
                        },
                    "Cancel": function () {
                        $(this).dialog("close");
                    }
                }
            });


        });  //end post
});

The partial page /Admin/EditUser looks like this:

@model TourSystem2.Models.UserEditViewModel
<link href="/Content/UserEdit.css" rel="stylesheet" type="text/css" />     
@Html.HiddenFor(Model => Model.UserInfo.iUserID)      
<table id="useredit">
    <tr>
        <td>@Html.LabelFor(Model => Model.UserInfo.cLoginName, "Login Name")</td>
        <td>@Html.TextBoxFor(Model => Model.UserInfo.cLoginName)</td>
    </tr>
    //Snip more fields
</table>

My controller code for EditUser looks like:

    public ActionResult EditUser(int UserID)
    {
        UserEditViewModel myUser = new UserEditViewModel();

        if (UserID == 0)
        {
            myUser.UserInfo.iUserID = 0;
            return PartialView("UserEdit", myUser);
        }
        else if (myUser.Load(UserID))
        {
            return PartialView("UserEdit", myUser);
        }
        else
        {
            return Json("Broken: " + myUser.Debug);
        }
    }

My intention is that upon clicking save, I will do another AJAX post to pass the information back to the server.

So far, everything is working pretty well except the value attribute of the textbox does not change even though the text in the box has changed. If I click on edit, the data files out correctly on the editUser partial page… but any changes are not reflected in the value.

Using firebug, I can visually see that value does not change for any textbox I have on the screen. During the “save user” post, only the original value is returned and not the modified value.

Did I miss something very basic?

*EDIT 1***
I am trying to do the following in my SaveButton event:

                    "Save": function () {
                        var myUser =
                            {
                                iUserID: ('#UserInfo_iUserID').val,
                                cLoginName: ('#UserInfo_cLoginName').val,
                            };
                            $.ajax({
                                type: "POST",
                                url: "/admin/SaveUser",
                                data: myUser,
                                success: function (bNum) {
                                    alert("returned" + bNum);
                                }
                            });

I am getting old results for the cLoginName: (‘#UserInfo_cLoginName’).val

This happens before the second POST.

  • 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-22T00:51:55+00:00Added an answer on May 22, 2026 at 12:51 am

    That’s a common gotcha when you try to modify values in a POST action that are contained in the ModelState and rendering the same view. You will need to remove the value from model state before changing it or HTML helpers (such as HiddenFor) will use the POSTed value when binding:

    ModelState.Remove("UserInfo.iUserID");
    myUser.UserInfo.iUserID = 0;
    return PartialView("UserEdit", myUser);
    

    Verify by debugging that ModelState contains a value called UserInfo.iUserID.


    UPDATE:

    It seems that the wrong syntax is used to retrieve the values:

    ('#UserInfo_iUserID').val
    

    instead of:

    $('#UserInfo_iUserID').val()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Visual Studio 2010 RTM with .NET/Entity Framework 4 RTM with a model
I recently updated Visual Studio 2010 to SP1 and noticed the .NET 4 framework
I am using Visual Studio 2010 RC1. I define a resource Brush2 in app.xaml_:
I'm using Visual Studio 2010 RC. Would it be possible that after doing my
I am using Visual Studio 2010 Ultimate Beta 2. What is the relevant namespace/classes
I'm running Windows 7 Ultimate (64 bit) using Visual Studio 2010 RC. I recently
For reference, I'm using Visual Studio 2010. I have a custom build step defined
I want to be able to develop code using Visual Studio 2010. I just
I am using the Visual Studio 2010 RC. Sometimes when I am working on
I'm using the Visual Studio 2010 RC for .NET 4.0 and I'm trying to

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.