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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:43:58+00:00 2026-05-19T21:43:58+00:00

Say I am implementing a view for Food. (ASP.NET MVC2) Then depending on the

  • 0

Say I am implementing a view for Food. (ASP.NET MVC2)

Then depending on the type (say fruit or vegetable for example) I will change the view.

Can I do this without creating a seperate view for fruit and vegetable?

I.e. Say we have url structure like http://localhost:xxxx/Food/{foodID}

and don’t want

http://localhost:xxxx/Veg/{foodID}

http://localhost:xxxx/Fruit/{foodID}

So I want to be able to change the view depending on the type. I’m using a tabstrip control from telerik, to give you an idea of the difference in the views – it’d just be say – not displaying one particular tab for Veg, and displaying it if fruit, for example.

Can a view accept two different view models ? so when we hit http://localhost:xxxx/Food/{foodID} the code determines what type the object is (Fruit or Vegetable) then sends either FruitViewModel or VegetableViewModel ? If I just send one viewmodel how can I control the logic to display or not display certain things in the 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-19T21:43:58+00:00Added an answer on May 19, 2026 at 9:43 pm

    If you define FoodViewModel as a base class and have FruitViewModel and VegetableViewModel extend it, you could have ViewPage<FoodViewModel> and pass in either. Then, your view can check for which specific subclass it got and render the appropriate output.

    Alternatively, if the only difference between FruitViewModel and VegetableViewModel is that one is Fruit and one is Vegetable (but all other properties are shared, i.e., Name, Calories, Color, Cost), have a FoodType property on the shared FoodViewModel and use it to conditionally render the appropriate output.

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

Sidebar

Related Questions

Multiple texts say that when implementing double-checked locking in .NET the field you are
I'm currently writing an ASP.Net app from the UI down. I'm implementing an MVP
We're currently rewriting our organizations ASP.NET MVC application which has been written twice already.
For the sake of argument, let's say I'm implementing Future for a task which
The question is quite theoretical. Let's say you're implementing a normal (or small or
Let's say you're implementing rails app for a snowboard rental store. A given snowboard
Lets say I am implementing a calculator which adds two numbers. Since we want
I am implementing two objects, say HotDog and Burger, and they are both subclass
How can I implement background processing queues in my ASP.NET MVC web app? While
Let's say I have an interface IAutoTask and few other classes implementing that interface,

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.