ASP.NET MVC Alternatively Rendering EditorFor Based on User Role

前端 未结 3 662
小鲜肉
小鲜肉 2020-12-17 21:51

I have a base viewmodel class that includes a current user property, and I need MVC to render a textbox or label according to the user\'s admin status.

Currently, I\

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-17 22:41

    Try to use extension methods. It is possible to create static class (cannot be non-static or nested) with methods you need, which one parameter is Html and it is marked using 'this' keyword. More information you can find here: http://msdn.microsoft.com/en-us/library/vstudio/bb383977.aspx

提交回复
热议问题