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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:48:01+00:00 2026-05-29T05:48:01+00:00

I am using ASP.NET MVC3 with the razor view engine. I am also using

  • 0

I am using ASP.NET MVC3 with the razor view engine. I am also using a the Yahoo User Interface 2 (YUI2) simple editor.

My view has a view model called ProductEditViewModel. In this view model I have a property defined as:

public string LongDescription { get; set; }

In my view I would create the YUI2 simple editor from this input field. The field is defined in the view like:

<td>@Html.TextAreaFor(x => x.LongDescription, new { cols = "75", rows = "10" })<br>
     @Html.ValidationMessageFor(x => x.LongDescription)
</td>

Here is a partial view of my Edit action method:

[Authorize]
[HttpPost]
[ValidateInput(false)]
public ActionResult Edit(ProductEditViewModel viewModel)
{
     if (!ModelState.IsValid)
     {
          // Check if valid
     }

     // I added this as a test to see what is returned
     string longDescription = viewModel.LongDescription;

     // Mapping
     Product product = new Product();
     product.InjectFrom(viewModel);

     // Update product in database
     productService.Update(product);

     return RedirectToRoute(Url.AdministrationProductIndex());
}

When I view the contents of the longDescription variable then it should contain the values from the editor. If I edit the contents in the editor then longDescription still only contains the original contents, not the updated contents. Why is this?

  • 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-29T05:48:02+00:00Added an answer on May 29, 2026 at 5:48 am

    I suspect that somewhere in your POST action you have written something like this:

    [Authorize]
    [HttpPost]
    [ValidateInput(false)]
    public ActionResult Edit(ProductEditViewModel viewModel)
    {
         ...
         viewModel.LongDescription = "some new contents";
         return View(viewModel);
    }
    

    If this is the case then you should make sure that you have cleared the value from the ModelState before modifying it because HTML helpers will always first use the value from model state and then from the model.

    So everytime you intend to manually modify some property of your view model inside a POST action make sure you remove it from modelstate:

    ModelState.Remove("LongDescription");
    viewModel.LongDescription = "some new contents";
    return View(viewModel);
    

    Now when the view is displayed, HTML helpers that depend on the LongDescription property will pick the new value instead of using the one that was initially submitted by the user.

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

Sidebar

Related Questions

I'm developing an ASP.NET MVC3 application using the new Razor view engine but I'm
We're using ASP.NET MVC3 with Razor View engine and standard HTML and jquery on
Is there any documentation on how to use the Razor view engine using ASP.NET
I am using ASP.NET MVC 3 with the Razor view engine . I have
I'm experimenting with an ASP.NET MVC 3 site, using razor as the view-engine. I
This question relates to ASP.NET MVC3 using the Razor Engine. What I need to
I am using ASP.NET MVC 3 with the razor view engine. I have the
I am using Razor view engine in ASP.Net MVC 3 RC 2. This is
Here's the situation: ASP.NET MVC 3 application using Razor as the view engine. Works
I am programming using ASP.NET MVC 3 with Razor view engine. Here's what I'd

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.