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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:51:03+00:00 2026-06-10T22:51:03+00:00

I’m new to ASP.NET MVC 3 and I’m trying to create a edit view

  • 0

I’m new to ASP.NET MVC 3 and I’m trying to create a edit view for a User-object that has a couple of relations. I have the basic edit-view for the user, split with tabs for each relation that needs to be handled.

Tab 1 = Edit User
Tab 2 = Create new Group Access (with a listing of current group access)
and so on…

I created a ViewModel for the edit-view:

public class UserViewModel
{
    public User User { get; set; }
    public GroupAccess GroupAccess { get; set; }
    public IEnumerable<GroupAccess> GroupAccessList { get; set; }
}

The edit-view:

@model Project.ViewModels.UserViewModel

<div class="row">
    <div class="span9">
        <div class="tabbable tabs-left">
            <ul class="nav nav-tabs">
                <li class="active"><a href="#tab1" data-toggle="tab">User Information</a></li>
                <li><a href="#tab3" data-toggle="tab">Group Access</a></li>
            </ul>

            <div class="tab-content">
                <div class="tab-pane active" id="tab1">
                    @{ Html.RenderPartial("User/_CreateEditUser", Model.User); }
                </div>

                <div class="tab-pane" id="tab3">
                    @{ Html.RenderPartial("User/_CreateGroupAccess", Model.GroupAccess); }
                    @{ Html.RenderPartial("User/_ViewGroupAccessByUser", Model.GroupAccessList); }
                </div>
            </div>
        </div>
    </div>

    @{ Html.RenderPartial("_SidebarPartial"); }

</div>

Each of the partialviews are strongly-typed against their respective object…

The partialviews posts to the same controller, UserController, to separate actions. Everything works fine when saving “correct” data but when some kind server-side error occurs I need to return to the edit-view somehow. If I receive a server-side error in the “CreateGroupAccess” action in the UserController…how do I get back to the edit-view with the UserId-parameter that is required?

I’m stuck and I’m guessing that I’m going in the wrong direction with the current solution.

Does anybody got any idea on how to best solve this scenario?

  • 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-06-10T22:51:05+00:00Added an answer on June 10, 2026 at 10:51 pm

    Make yourself an BaseController:

    BaseController

    public class BaseController : Controller {
       protected const String ModelStateTempData = "ModelStateTempData";
       protected Boolean PreserveModelState { get; set; }
    
       protected override RedirectToRouteResult RedirectToAction(string actionName, string controllerName, System.Web.Routing.RouteValueDictionary routeValues)
        {
            if(PreserveModelState)
              TempData[ModelStateTempData] = ModelState;
    
            return base.RedirectToAction(actionName, controllerName, routeValues);
        }
    
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
          if (TempData[ModelStateTempData] != null && !ModelState.Equals(TempData[ModelStateTempData]))
                ModelState.Merge((ModelStateDictionary)TempData[ModelStateTempData]);
    
          base.OnActionExecuting(filterContext);
        }
    }
    

    SomeOtherController

    public class SomeController : BaseController {
      public ActionResult SomeAction(FormCollection collection) {
        if(ModelState.IsValid) {
          //Do something
          return SomeThingValidHappened();
        }
    
        //Not Valid
        PreserveModelState = true;
        return RedirectToAction("myAction");
      }
    }
    
    • 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 create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.