Escaping single quote from an MVC 3 Razor View variable

前端 未结 3 2070
执笔经年
执笔经年 2021-01-18 11:50

I have a variable within item.Name that contains the string \"It\'s Tuesday!\". To alleviate javascript errors, in the c# controller I have already escaped this single quot

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-18 12:12

    I prefer to make my views dumb. Therefore, I'd have a property called something like 'Display' or 'DisplayName' which handled the escaping for the view.

提交回复
热议问题