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 c
Your View Should be something like:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
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.