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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:36:25+00:00 2026-05-11T17:36:25+00:00

The ASP.net page I am currently working on has a drop down list that

  • 0

The ASP.net page I am currently working on has a drop down list that is intended to have a list of filters. When the user selects the filter, I would like to display a user control that has properties appropriate for the filter.

Here is the controller action in question:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection collection)
{
  var filterType =  Request.Form["FilterSelect"];
  ViewData["FilterChosen"] = filterType;
  PopulateSelectionFiltersData();//This method fills up the drop down list
  //Here is where I would like to switch based on the filterType variable
  return View();
}

The filter type variable has the correct value, but I’m unsure as to how to do the next part.

Also, as a corollary question, what would be the best way to persist the selected drop down value between calls?

Many thanks,

KevDog

  • 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-11T17:36:25+00:00Added an answer on May 11, 2026 at 5:36 pm

    Store the correct control to display in ViewData. As for persisting the menus,
    your choices are the Cache (used by many sessions), Session (used only by this session), or TempData (used only for the next method in this session). Alternatively, you could have it cached in your DataLayer. Typically, I just refetch the data until it becomes a performance issue — which it usually doesn’t.

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Index(FormCollection collection)
    {
      var filterType =  Request.Form["FilterSelect"];
      ViewData["FilterChosen"] = filterType;
      PopulateSelectionFiltersData();//This method fills up the drop down list
    
      string userControl = "DefaultControl";
      switch (filterType)
      {
          case "TypeA":
             userControl = "TypeAControl";
             break;
          ...
      }
    
      ViewData["SelectedControl"] = userControl; 
      return View();
    }
    
    
     <% Html.RenderPartial( ViewData["SelectedControl"], Model, ViewData ); %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on an ASP.net c# project. I have an aspx page
I currently have an ASP.NET GridView that displays a few columns to the user
I have a ASP.NET page with an asp:button that is not visible. I can't
I'll have an ASP.net page that creates some Excel Sheets and sends them to
I have an ASP.Net page that will be hosted on a couple different servers,
I have an ASP.NET page which has a script manager on it. <form id=form1
I am currently working on an asp.net web page with a GridView displaying a
Background: I am working on an ASP.NET MVC app that has 3 partials (based
I have an ASP.NET website that has been deployed since 2008 with plenty of
I am currently working on an ASP.NET MVC3 website. I have a simple authentication

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.