ASP.NET MVC Alternatively Rendering EditorFor Based on User Role

前端 未结 3 532
小鲜肉
小鲜肉 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:38

    You can create a HTML helper method. One way of doing this is by creating a new class with a static method that returns a string of html for rendering. Or you can extend the existing html helper class.

    There is a great asp.net walkthrough on it here: http://www.asp.net/mvc/tutorials/older-versions/views/creating-custom-html-helpers-cs

提交回复
热议问题