MVC3 Html.DisplayFor — Is it possible to have this control generate an ID?

前端 未结 7 1861
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-08 17:16

I want to be able to display some text, but also have the text be modifiable via jQuery.

<%= Html.DisplayFor(model => model.DeviceComponentName)%>
         


        
7条回答
  •  南旧
    南旧 (楼主)
    2021-02-08 17:59

    Just add a HiddenFor above the column. This will give you a ID to use for what you need. Simple and does the trick for you to grab that value by ID.

    <%= Html.HiddenFor(model => model.DeviceComponentName)%>
    <%= Html.DisplayFor(model => model.DeviceComponentName)%>
    

提交回复
热议问题