I have created json variable called "grouptypejson" as mentioned below:-
var grouptypejson = {
"opt": [
{
"n": "@SampleResource.GENERIC",
"v": 0
},
{
"n": "@SampleResource.DEPARTMENT",
"v": 1
}
]
};
The above json variable is defined globally in cshtml page under javascript body.
I am using hardcoded value i.e. "v":0 & "v":1
Instead of using hardcoded value, I want to get the number via enum which is defined under models namespace i.e. mentioned below:-
namespace My.Sample.Models.Enums
{
public enum FilterEnum
{
Generic = 0,
Department,
All
}
}
I want to read the value using the above enum and store the same at hard coded place
i.e. "v":0 & "v":1
I don't know how to get the enum value as integer and store at "v".
I tried using the following mentioned below but the result was Generic & Department respectively. Replaced 0 & 1 with the below string at the above json variable.
"v":"@FilterEnum.GENERIC" & "v":"@FilterEnum.DEPARTMENT"
Please guide me how to do the same, I am including the enum namespace in my html page.
Please correct me if i have written anything wrong. I am beginner & learner.
Thanks in advance.