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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:15:40+00:00 2026-05-20T14:15:40+00:00

I’m trying to figure out why why and how EditorFor caches information. This is

  • 0

I’m trying to figure out why why and how EditorFor caches information.

This is a simple program that has one two textareas. One for input and one for output. The reason for a text area for output is that it makes a select all copy easier.

My code is pretty simple. First my controller puts some default value

    public ActionResult MoveCss()
    {
        MoveCssIO model = new MoveCssIO(); ;
        model.InputCss = "Fish";
        return View(model);
    }

Then my model kicks in and makes output the uppercase of input

    [Required(ErrorMessage="Please provide some text to transform")]
    [DataType(DataType.MultilineText)]
    public string InputCss { get; set; }


    private string _OutputCss;

    [DataType(DataType.MultilineText)]
    public string OutputCss { 
        get
        {
            Transform();
            return _OutputCss;
        }
        set
        {
            _OutputCss = value;
        }
    }

    private void Transform()
    {
        if (!string.IsNullOrWhiteSpace(InputCss))
        {
            _OutputCss = InputCss.ToUpper();
        }
    }

This goes to my view

##
@Html.Encode(Model.OutputCss)
$$
@Html.DisplayFor(model => model.OutputCss)
&&
@Html.EditorFor(model => model.OutputCss)
%%

So at initial load I get

##
FISH
$$
FISH
&&
<textarea class="text-box multi-line" id="OutputCss" name="OutputCss">
FISH</textarea>
%%

I then use an editor for InputCss (not shown) to change the value on InputCss to ham

    [HttpPost]
    public ActionResult MoveCss(MoveCssIO model)
    {
        return View(model);
    }

This set my OutputCss to HAM and the page does a reload (no ajax) but when I get for output is

##
HAM
$$
HAM
&&
<textarea class="text-box multi-line" id="OutputCss" name="OutputCss">
FISH</textarea>
%%

My question is why is the value in Html.EditorFor different than Html.DisplayFor and how do i fix this?

Updated: To add a bit of clarity

  • 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-20T14:15:41+00:00Added an answer on May 20, 2026 at 2:15 pm

    Your question is extremely unclear but I suspect that you are trying to modify some value in a POST action and you are still seeing the old value when the view is rendered. If this is the case you need to remove it from the modelstate or html helpers will always bind the old value:

    [HttpPost]
    public ActionResult MoveCss(MoveCssIO model)
    {
        // you are changing a POSTed value here so make sure
        // you remove it from the model state or HTML helpers 
        // will use the original value
        model.InputCss = "ham"; 
        ModelState.Remove("InputCss");
        return View(model);
    }
    

    Also note that there is absolutely no caching involved with editor/display templates.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.