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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:56:34+00:00 2026-05-15T06:56:34+00:00

I would like to strip out non-numeric elements from the POST data before using

  • 0

I would like to strip out non-numeric elements from the POST data before using UpdateModel to update the copy in the database. Is there a way to do this?

// TODO: it appears I don't even use the parameter given at all, and all the magic
// happens via UpdateModel and the "controller's current value provider"?
[HttpPost]
public ActionResult Index([Bind(Include="X1, X2")] Team model) // TODO: stupid magic strings
{
    if (this.ModelState.IsValid)
    {
        TeamContainer context = new TeamContainer();

        Team thisTeam = context.Teams.Single(t => t.TeamId == this.CurrentTeamId);
        // TODO HERE: apply StripWhitespace() to the data before using UpdateModel.
        // The data is currently somewhere in the "current value provider"?
        this.UpdateModel(thisTeam);
        context.SaveChanges();

        this.RedirectToAction(c => c.Index());
    }
    else
    {
        this.ModelState.AddModelError("", "Please enter two valid Xs.");
    }

    // If we got this far, something failed; redisplay the form.
    return this.View(model);
}

Sorry for the terseness, up all night working on this; hopefully my question is clear enough? Also sorry since this is kind of a newbie question that I might be able to get with a few hours of documentation-trawling, but I’m time-pressured… bleh.

  • 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-15T06:56:35+00:00Added an answer on May 15, 2026 at 6:56 am

    Instead of using the automatic model-binding in your action method’s parameters, you could accept the posted FormCollection and work with that. You might be able to (1) modify the values in this special collection, then (2) bind your model manually, using UpdateModel/TryUpdateModel.

    for example,

    public ActionResult Index(FormCollection formCollection)
    {
        DoWhateverToFormCollection(formCollection);
        Team model;
        // TO-DO: Use TryUpdateModel here and handle more nicely
        // Should also pass in binding whitelist/blacklist to the following, if didn't remove from the formCollection already...
        UpdateModel<Team>(model, formCollection);    
        // rest of your code...
    
    }
    

    Hopefully this should work as advertised, and best of luck!

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

Sidebar

Ask A Question

Stats

  • Questions 439k
  • Answers 439k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I solved it like this. There are probably other solutions… May 15, 2026 at 4:50 pm
  • Editorial Team
    Editorial Team added an answer I fixed it by creating two symbolic links /usr/lib/gcc ->… May 15, 2026 at 4:50 pm
  • Editorial Team
    Editorial Team added an answer There's built-in support for this, having an icon or button… May 15, 2026 at 4:50 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.