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

  • Home
  • SEARCH
  • 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 587355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:12:13+00:00 2026-05-13T15:12:13+00:00

In ASP.Net MVC I would like to render a different partial view depending on

  • 0

In ASP.Net MVC I would like to render a different partial view depending on the renderview query string parameter.

Therefore providing the facility for the user to choose to view products by thumbnail or by details.

I have access to the chosen parameter in the controller but I do not know how to or, if I should be passing this to the view along with the products list so the view can implement the logic for deciding which partial view to display?

public ActionResult Products(string id, int? renderview)
{
    var products = productRepository.GetProducts(id).ToList();
    return View("Products", products);
}



<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MLBWebRole.Models.Product>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Products
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>Products</h2>

<p>This is the Products page</p>

<p><a href="?renderview=0">thumbnails</a>&nbsp;<a href="?renderview=1">details</a></p>


 <% if (renderview == 1)
     {%>
    <% Html.RenderPartial("ProductsDetailList"); %>
<% }
else
 { %>
<% Html.RenderPartial("ProductsThumbnailList"); %> 
  <% } %>

</asp:Content>
  • 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-13T15:12:13+00:00Added an answer on May 13, 2026 at 3:12 pm

    Your View Should be something like:

    <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Models.MyModel>" %>
    

    Then in MyModel

    Expose Property:

    public bool RenderDetailView {get;set;}
    

    In your controller action:

    public ActionResult Products(string id, int? renderview)
    {
        var products = productRepository.GetProducts(id).ToList();
        return View("Products", new MyModel {RenderDetailView = renderview.HasValue});
    }
    

    Then in your view, make check like:

    <% if (Model.RenderDetailView)
    

    Ideally, all the properties or parameters or data which a View needs in order to present itself should be part of Model.

    I hope it helps.

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

Sidebar

Ask A Question

Stats

  • Questions 314k
  • Answers 314k
  • 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 Underscores used in place of variable names like that are… May 13, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer if [[ $# -eq 0 ]] ; then echo 'some… May 13, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer Try the following //part of the usings using System.Runtime.InteropServices; //declares… May 13, 2026 at 10:59 pm

Related Questions

I would like to render a list of HTML links in ASP.NET MVC. Note
In asp.net mvc, I have been thinking it would be more advantageous to specify
I wonder, is there an equivalent of the Monorail View components for Asp.Net MVC?
Scenario : I have an ASP.NET MVC application developed in Visual Studio 2008. There
I'm trying to learn the new ASP .NET MVC framework and would like to

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.