[Flags]
public enum Category
{
Undefined = 0,
AdultsOnly = 1,
Family = 2,
AllInclusive = 4,
City = 8
}
void Main()
{
Category c = Category.AdultsOnly | Category.City; Category[] categories = new Category[2] { Category.AllInclusive, Category.Family};
Category category = categories.Aggregate((i, t) => i | t);
var isThereAtLeastOneMatch = (c & category) != Category.Undefined;
var hasExact = (c & Category.AdultsOnly )== Category.AdultsOnly;
}
Jun 14, 2018
.NET C# Operations with flagged Enumerations
Jun 11, 2018
asp.net core 2.0 DataFormatString DisplayFor
Propert display formatting that worked in ASP.NET Core 2.0 :
<span class="room-price">@(Html.DisplayFor(m => rate.Price))€</span>
<span class="room-price">@(Html.DisplayFor(m => rate.Price))€</span>
[DisplayFormat(DataFormatString = "{0:#,###.00}", ApplyFormatInEditMode =false, NullDisplayText ="")]
public decimal Price { get; set; }
Important! Don't use DisplayTextFor!
Important! Don't use DisplayTextFor!
Jun 7, 2018
asp.net mvc core 2.0 validating checkbox
Explains how to force required on checkbox.
<input type="checkbox" id="TermsOfUseFake">
<label for="TermsOfUseFake"><a href='@navLinks.GetSitePageLink(languageGroupId: "TermsOfUse")' target="_blank">@Localizer["Loyalty.RegisterForm.TermsOfUse"]</a></label><br>
<input style="width:0px;border:0px!important;padding:0px;" type="text" asp-for="TermsOfUse" />
<span asp-validation-for="TermsOfUse" class="text-danger"></span>
$(document).on('change', '#TermsOfUseFake', function () {
debugger;
if ($('#TermsOfUseFake:checked')[0]) {
$('#TermsOfUse').val("true");
}
else {
$('#TermsOfUse').val("");
}
$("form#registerForm").validate().element("#TermsOfUse");
});
ASP.NET MVC Core 2.0 - Resource Key is not compiled from RESX file
Open RESX and change Access Modifier to Public.
Make sure that project builds without error. You can be misled that RESX cant be built while you have compile error.
Make sure that project builds without error. You can be misled that RESX cant be built while you have compile error.
Subscribe to:
Posts (Atom)