Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的 MVC 4 视图中动态生成 DIV 的 ID 标签:
<div id="newBox{0}"></div>
并将 {0} 替换为 @Model.MyTag
最好的做法是什么?
<div id="newBox@(Model.MyTag)"></div>
或者
<div id="newBox@{Write(Model.MyTag);}"></div>
两者都进行 HTML 编码(特殊字符安全)。