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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:48:53+00:00 2026-06-07T17:48:53+00:00

In my model class I have a boolean property DoNotEmail . In the UI

  • 0

In my model class I have a boolean property DoNotEmail.

In the UI design I’ve been given to create a view for, the meaning of the checkbox is inverted; i.e. the label next to the checkbox says "Send Email".

Normally I would add the checkbox like this: @Html.CheckBoxFor(model => model.DoNotEmail) but clearly this is the wrong way round.

Do I need to create a separate view model with a custom property for this checkbox, or is there some clever way I can do something like: @Html.CheckBoxFor(model => !model.DoNotEmail) (which clearly doesn’t work)?

  • 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-06-07T17:48:56+00:00Added an answer on June 7, 2026 at 5:48 pm

    Passing entities directly to your view is never a good idea, if your DB schema ever changes you would have to go through all your views and update them. I would recommend creating a ViewModel and passing only the data required for the view, then map your DoNotEmail property in the controller. That way you maintain the abstraction between your model/view and keeps your view simple e.g.

    public void ViewModel
    {
        [DisplayName("Send Email")]
        public bool SendEmailNotification { get; set; }
    }
    

    View

    @model ViewModel
    
    @Html.CheckBoxFor(m => m.SendEmailNotifications)
    

    Controller

    public void Post(ViewModel model)
    {
        var entity = ...;
        entity.DoNotEmail = !model.SendEmailNotification;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this model class User include DataMapper::Resource include BCrypt property :id, Serial property
I have a model which has a boolean property and some other properties that
I have the following model in datamapper: class Student include DataMapper::Resource property :id, Serial
I have a model with a reference property, eg: class Data(db.Model): x = db.IntegerProperty()
I have a class Model: class Model { ... boost::shared_ptr<Deck> _deck; boost::shared_ptr<CardStack> _stack[22]; };
Assume I have this model : class Task(models.Model): title = models.CharField() Now I would
I have a Meeting model: class Meeting < ActiveRecord::Base has_one :location, :class_name => MeetingLocation,
I have this Project model: class Project < ActiveRecord::Base validates :status, :inclusion => {
I have a model class similar to the following: using System; using System.Collections.Generic; using
I have a simple model class (Part), which pulls from it's information from 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.