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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:37:37+00:00 2026-05-21T16:37:37+00:00

I need a quick sanity check. I’m trying to design my views such that

  • 0

I need a quick sanity check. I’m trying to design my views such that they are clean, concise, and as free from any sort of conditional logic as possible. However, I’m having a hard time ridding them of all conditional statements. I’m wondering if having some conditional statements in views is unavoidable?

For example:

@if (Model.UserCanEdit)
{
    <button type="button" id="Edit">Edit</button>
}

There are not many options if you have a view that has several elements that can change or be shown/hidden depending on various conditions.

So what guidelines should I follow regarding where to draw the line on allowing conditional logic in your views? What are some ways to reduce conditional logic in my views that I may not be thinking of?

Thanks in advance.

  • 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-21T16:37:38+00:00Added an answer on May 21, 2026 at 4:37 pm

    I wouldn’t say that it is all bad using conditionals in Views – after all the main purpose of a view is actually displaying data from your Model. (And some times conditional statements are required to display the data.)

    However – using an abundance of
    conditionals can make maintenance a
    nightmare and eventually readability.
    It’s important to remember to not
    include conditionals to the extent of
    becoming business logic, but allow
    them to serve their purpose as
    “presentation logic”.

    Possible Alternatives:

    Custom HTML Helpers:

    If you aren’t crazy about using conditionals – you can look into using Helpers to clean up things a bit. For more information on that check out Creating Custom HTML Helpers.

    Additional Views / Partial Views:

    Also, as many will point out – using conditionals to make a single view function as multiple views should is not the best way to tackle that issue.

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

Sidebar

Related Questions

I need a quick algorithm to select 5 random elements from a generic list.
I need a quick easy way to get a string from a file in
Need Quick and fast list of configuration changes required while moving from single-tier to
I have some (small amount) of data that I'll need quick access to on
I have a quick question that I need some help with if possible. Am
Here is the situation: I have a huge data set that I need quick
i need a quick hint regarding the following exercise question: Write a program that
I need some quick advice. I would like to simulate a cellular automata (from
What are your best usability testing tips? I need quick & cheap.
I need a quick yes/no answer on this... Is it possible to get a

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.