How to set disabled in MVC htmlAttribute

后端 未结 8 2354
刺人心
刺人心 2020-12-30 02:06

When using an HTML Helper, what is the best method to set an attribute based on a condition. For example

<%if (Page.User.IsInRole(\"administrator\")) {%&g         


        
8条回答
  •  庸人自扰
    2020-12-30 02:18

    I could suggest you to use mvccontrib.FluentHtml.

    You can do something like this

     <%=this.TextBox(m=>m.FirstNam ).Disabled(Page.User.IsInRole("administrator"))%>
    

提交回复
热议问题