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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:12:31+00:00 2026-05-29T07:12:31+00:00

I have a view that is comprised of 3 partial views 2 partials at

  • 0

I have a view that is comprised of 3 partial views
2 partials at the top on left and right of screen.
Each one has a mutually exclusive search and each post back to their own action

This is the action that renders the initial view

    public ActionResult Index() {
        var model = new SearchOptionsViewModel();
        return View(model);
    }

This is the post action for one of the partial view:

    [HttpPost]
    public ActionResult SearchByUser(UserSearchOptionsViewModel model) {
        if(ModelState.IsValid) {
            var list = SearchUserService.SearchByValue(model.LastName, model.Username, model.EmailAddress);
            if(list != null) {
                var resultsModel = new UserSearchResultsListViewModel();
                list.ForEach(item => resultsModel.Users.Add(new UserSearchResultsViewModel(item)));
                return RedirectToAction("SearchResults", resultsModel);
            }
        }
        return View(model);
    }

This model successfully posts and gets my data from the db and adds it to the viewmodel.
I’m lost on as to how to get the results to show on the same screen underneath the search criteria.

This is the action that I was hoping would work to receive the model from the prior action and render the partial back to the original view. I thought using a 3rd SearchResults partialview was the answer but that doesn’t work, it navigates to it’s own page showing the results instead of on the same page.

    public ActionResult SearchResults(UserSearchResultsListViewModel model) {
        return PartialView(model);
    }

Model always comes in as null when I do this. I’m missing something fundamental here…
How do I get this data to show on the same View?

  • 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-29T07:12:34+00:00Added an answer on May 29, 2026 at 7:12 am

    This is what I ended up doing. It doesn’t feel completely clean but I’ve kept the responsibilities of the methods minimal. I’d like to have a better way of doing this without TempData if anyone has a better suggestions please post your example.

        // Inital loaded view with 3 partial views
        // 2 for search criteria, 1 for results
        public ActionResult Index() {
            var model = new SearchUsersViewModel();
            if(TempData["model"] != null)
                model = (SearchUsersViewModel)TempData["model"];
            return View(model);
        }
    
        // Post the search criteria model for search 
        // by user data (by last name, etc...)
        // Then redirect back to Index.
        // TempData will have the full model with results populated
        [HttpPost]
        public ActionResult SearchByUser(FilterUsersByUserDataViewModel model) {
            if(ModelState.IsValid) {
                var list = SearchUserService.SearchByValue(model.LastName, 
                                                           model.Username,
                                                           model.EmailAddress);
                if(list != null) {
                    TempData["model"] = PrepareResultsModel(list);
                    return RedirectToAction("Index");
                }
            }
            return View(model);
        }
    
        // This method just separates the concern of creating 
        //the new full model with search results populating the results view
        private SearchUsersViewModel PrepareResultsModel(List<SearchUserViewDTO> list) {
            var searchResults = new UserSearchResultsViewModel();
            list.ForEach(item => searchResults.Users.Add(new UserViewModel(item)));
            var model = new SearchUsersViewModel();
            model.UserSearchResultsViewModel = searchResults;
            return model;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of Controller/View that are composed dynamically, each one have a
I am beginner in rails. I have view that i try to print inside
I have a view that is loaded in the MainWindow.xib. It is just a
I have a view that takes data from my site and then makes it
I have a view that I want to be converted into JSON. What is
I have a view that contains two NSTextFieldCell s. The size at which these
I have a view that will be displaying downloaded images and text. I'd like
We have a view that, without constraints, will return 90 million rows and a
I have a View that renders something like this: Item 1 and Item 2
I have a view that I'm trying to filter with something similar to DISTINCT

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.