How can I use Enums on my Razor page in MVC3?

前端 未结 3 783
一整个雨季
一整个雨季 2021-02-18 20:17

I declared an enum:

public enum HeightTypes{    Tall,    Short}

Now I want to use it on my razor page like this:

@if (Model.Met         


        
3条回答
  •  醉酒成梦
    2021-02-18 20:51

    You aren't specific about the exception, so I'm guessing this is a namespace issue. Add

    @using The.Namespace.Of.Your.Enum;
    

    at the top. You can also specify namespaces to add automatically in /Views/web.config if you are going to use that namespace a lot:

    
        ...
        
            
                
                ...
                
    

提交回复
热议问题