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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:25:13+00:00 2026-05-27T00:25:13+00:00

I have been learning .MVC recently and am having trouble understanding how to process

  • 0

I have been learning .MVC recently and am having trouble understanding how to process a viewmodel when posted back. I have followed the example here: http://www.shawnmclean.com/blog/2011/04/asp-net-mvc-multiple-check-boxes-in-an-array-or-list/#codesyntax_2 My problem is how do we handle the viewmodel when posted back so that a user is save with the correct roles? Do I have to manually pull the values out of the viewmodel and assign the selected roles to the user?

All help appreciated!

James

  • 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-27T00:25:14+00:00Added an answer on May 27, 2026 at 12:25 am

    Yes, you have to. This is the code from the your link handling that.
    The Action receives the ViewModel object and calls a Method in some UserService which does the actual work:

    [HttpPost]
    public ActionResult EditUserRole(UserRoleViewModel model)
    {
        List<Role> roles = model.Roles.Where(r => r.IsInRole)
                .Select(r => new Role {RoleId = r.RoleId, RoleName = r.RoleName})
                .ToList();
        userService.AddRolesToUser(model.UserId, roles);
        return View();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been learning MVC recently and have started creating my own framework (for
I have been learning ASP.NET MVC in the last few months and I think
I have been learning ASP.NET MVC for a few months. I have learned about
I have been learning to develop websites using ASP.NET MVC 2 for work... and
I have been learning java spring hibernate MVC for 3 months and got pretty
In my class we have been learning about different designs such as MVC and
I am learning asp.net MVC, as I have been using the sqlconnection, sqlcommands etc
I'm working on an ASP.Net MVC project and have been learning a few little
Im learning asp.net mvc and have been investigating jquery and the like. As yet
I have been working on a little MVC project to assist in my self-learning

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.