I have the following enum
public enum Tipo
{
Tipo0 = 0,
Tipo1 = 1,
Tipo2 = 2,
Tipo3 = 3
}
Which I use in my model in the following way
public class MiModeloViewModel
{
public Enums.Tipo Tipo { get; set; }
}
From the view all this becomes a input type hidden
(how can I convert this line into razor?)
<input type="hidden" id="Tipo" name="Tipo" value="@Tipo.Tipo1" />
The first problem I have is that in the value
I have the text of my enum
in this case would be value="Tipo1"
what I need is that the value remains in full, for this I solve adding a value="@Tipo.Tipo1.GetHashCode()"
doing that now looks like value="1"
.
But at the moment of sending my form, in my model it brings me again the string value of that enum
. What can I do to get the whole back?
Do something like
public class MiModeloViewModel
{
public Enums.Tipo.GetHashCode() Tipo { get; set; }
}
Clearly this does not work ... but that's the idea that instead contain the string of my enum
containing the int
.