After reading this post JSON serialization of enum as string I'm still searching for a quick way to use into Razor javascript this type of Enum:
[JsonConverter(typeof(StringEnumConverter))]
public enum StatusReplacement
{
ApprovalPending = 1,
Canceled = 2,
Approved = 3,
AwaitingDelivery = 4,
Delivered = 5,
Completed = 6
}
By using JsonConverter I just can take the element enums but not their values. I also tried unsuccessfully to set over each element [EnumMember(Value = "")].
Expected result
...Razor...
<script>
var elementValue = @StatusReplacement.ApprovalPending;
alert(elementValue) //Expecting to return 1 instead of ApprovalPending *undefined.
</script>
I'm not sure yet if I really have use any king of html helper for this purpose. I suspicious there is an easier way to achieve it today working with MVC 4+.
Regards, Rubens