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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:59:45+00:00 2026-05-27T20:59:45+00:00

I have a simple ASP.NET MVC 3 dummy app (just learning MVC coming from

  • 0

I have a simple ASP.NET MVC 3 dummy app (just learning MVC coming from WebForms).

And I’m pretty confused about how to update a form without actually having some DB stuff in between. I just have a form with a textbox and after I press the button I want to see the string in uppercase. But my nothing happens.

The controller:

    public ActionResult Index()
    {
        ToUppercaseModel model = new ToUppercaseModel { TheString = "testing" };

        return View(model);
    }

    [HttpPost]
    public ActionResult Index(ToUppercaseModel model)
    {
        model.TheString = model.TheString.ToUpper();

        return View(model);
    }

The model:

public class ToUppercaseModel
{
    [Display(Name = "My String")]
    public string TheString { get; set; }
}

And the view:

@using (Html.BeginForm()) {
    <div>
        <div class="editor-label">
            @Html.LabelFor(m => m.TheString)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(m => m.TheString)
        </div>
        <p>
            <input type="submit" value="Convert" />
        </p>
    </div>
}

This is a simple as it gets I think. Now obviously the return View(model); in the 2nd Index method is not working. I saw some stuff about RedirectToAction() and storing the data in TempData. Most example just submit some id, but since I don’t have db that does not work.

If I do this:

return RedirectToAction("Index", model);

I get a

No parameterless constructor defined for this object.

Error Message. This should be simple, no? I think I understand the Post/Redirect/Get concept, but don’t see how to apply it for something simple as this.

Thanks for some clarification.

  • 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-27T20:59:46+00:00Added an answer on May 27, 2026 at 8:59 pm

    When MVC renders a view it will use the attempted value of a field rather than the model’s value if it exists (eg in a datefield I put “Tuesday”, this won’t model bind but you’ll want to show the user the field with their input and highlighted as invalid), you’re changing the model’s value but not the attempted value.

    The attempted value is held in the modelstate dictionary:

    ModelState["KeyToMyValue"].Value.Value.AttemptedValue

    Accessing and changing these values can be tricky unless you want a load of magic strings in your code, and as validation happens on modelbinding your changed value won’t be validated.

    My recommendation in these circumstances is to call ModelState.Clear(), this will remove all validation and attempted values, then change your model directly. Finally you want to get your validation on the model by using TryValidateModel(yourModel).

    Be aware that this method is probably the easiest non-hacky method of doing this but will remove attempted values that could not bind from the returned view.

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

Sidebar

Related Questions

I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything
I have a simple ASP.NET MVC + OpenID + NHibernate app (on top of
I have a very simple asp.net mvc web app which uses castle active record,
I have a pretty simple ASP.NET MVC Site Application. (MVC 1.0) I have NO
I have a simple ASP.NET MVC 3 site, from my Controller out of the
I'm a newbie about ASP.NET MVC 3, but I have a simple question. Is
I have a simple ASP.NET MVC 1.0 site w/ Home, Upload, and About links
I have a very simple ASP.Net MVC Application that I have produced from an
I have a pretty simple ASP.NET MVC page and am using TinyMCE to allow
I have a very simple ASP.NET MVC site which displays images from the database.

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.