Enums with jQuery?
You would have to duplicate the enum in JavaScript like so:
var myEnum = { OneValue: 2, AnotherValue: 3};
then you can use it like this:
this.value === myEnum.OneValue || this.value === myEnum.AnotherValue;
Im using this way:If you got a enum anywhere in your c# project like :
public enum MyEnum { One = 1, Two= 2 }
(Supposing you wanna use it your entire project)In your Shared.Layout.cshtml file , at first line put its reference like bellow
@using MyProject.NameSpace.MyEnum
Inside Layout.cshml, at section put something like bellow
<script> const myEnum = { One : @Convert.ToInt16(MyProject.NameSpace.MyEnum.One), Two : @Convert.ToInt16(MyProject.NameSpace.MyEnum.Two) }</script>
In other places just compare something like
<script>if(AnyValue == myEnum.One){console.log(myEnum.One)}</script>