I'm not able to get a clear answer on my problem: I want to have one partial view but have 3 distinct code blocks within the partial with similar (not exactly the same) content. So that whatever view page is loaded will determine which of the 3 code blocks is displayed in the partial view.
I did something similar back in MVC2, but it was on the controller level (controller determined which of the 3 code blocks was displayed). Now I have a need to go deeper and do it on the page level.
I understand that a bunch of if/else statements in a view is not the MVC convention. But honestly, that's the only way I know how to do it. An alternative is to keep this if/else logic and create more than one controller and keep doing it the old way.
Can anyone point me in the right direction?
There's at least 4 ways you could do this.
Hard to advise on which one, given you haven't supplied much code and you haven't said what's different about the 3 pieces of content.
I usually go with option 4 because it's the cleanest and most versatile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With