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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:03:07+00:00 2026-05-25T16:03:07+00:00

Getting up to speed on MVC 3, Having a problem with an [HttpPost] ActionResult

  • 0

Getting up to speed on MVC 3,

Having a problem with an [HttpPost] ActionResult method seeing passed data, depending on whether I use EditorFor() or TextBoxFor() in my view.

I have some fields in my Edit View that I want to be read-only so I have used:

<div class="editor-field">
    @Html.EditorFor(model => model.ModelNumber)
    @*Html.TextBoxFor(model => model.ModelNumber, new { disabled = "disabled", @readonly =      "readonly" })*@
    @*Html.ValidationMessageFor(model => model.ModelNumber)*@
    </div> 

Here is the ActionResult controller methods:

 public ActionResult Edit(int id)
    {
        var NPSProc = db.NPSProcesseds.SingleOrDefault(p => p.Id == id);
        return View(NPSProc);
    }

    [HttpPost]
    public ActionResult Edit(NPSProcessed Processed)
    {
        try
        {

            if (ModelState.IsValid)
            {
                db.Entry(Processed).State = EntityState.Modified;
                db.SaveChanges();
                return new RedirectResult("~/Home", false);
            }
            else
            {
                return View("Edit", Processed);
            }
        }
        catch (DbEntityValidationException dbEx)
        {
            foreach (var validationErrors in dbEx.EntityValidationErrors)
            {
                foreach (var validationError in validationErrors.ValidationErrors)
                {
                    Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                }
            }

            return View("Edit", Processed);
        }

When I remove the comments on the EditorFor() method, the ModelNumber field contains a value ModelNumber in the Processed object passed to the HttpPost ActionResult Method.

If I comment the EditorFor() method and remove the comment on the TextBoxFor() method
the MethodNumber field contains a null.

It appears that EditorFor() Method is performing some additional work that TextBoxFor() method is not doing.

Could someone point me in the correct direction and point out the error that I am making.

Thanks

Joe

  • 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-25T16:03:07+00:00Added an answer on May 25, 2026 at 4:03 pm

    Disabled <input> elements aren’t posted back to the server.

    Because you set disabled="disabled" in the TextBoxFor, the browser never sends that value back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting up to speed on rails and ran into an odd problem. I'm
I'm just getting up to speed with asp.net mvc and I'm wondering how one
It's kind of subjective, but I'm having troubles getting LLVM JIT up to speed.
I'm just getting up to speed on MVVM, but all the examples I've seen
One thing that's really been making life difficult in getting up to speed on
I am using ARM926EJS. I am getting 20 % more memory speed in memory
Getting started with jquery and having trouble getting hello world type example going for
I am working on a few PHP projects that use MVC frameworks, and while
Using Getting back up to speed on Java after 8-10 years as a starting
I'm getting no improvement in speed when using Ehcache with Hibernate Here are the

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.