asp.net-mvc – mvc razor @helper可以返回非编码标签吗?
发布时间:2021-01-11 12:41:17 所属栏目:asp.Net 来源:互联网
导读:这是做的,但它基本上是我在做什么.我有一个这样的@helper: @helper MyImage(int i) { String s = img src={0} /; String theImage = ; switch(i) { case 0: theImage = test1.png; break; case 1: t
这是做的,但它基本上是我在做什么.我有一个这样的@helper: @helper MyImage(int i) { String s = "<img src='{0}' />"; String theImage = ""; switch(i) { case 0: theImage = "test1.png"; break; case 1: theImage = "test2.png"; break; default: theImage = "error.png"; break; } String r = String.Format(s,theImage); @(r) } 我在网页上输出的输出当然是实际的字符串: <img src='test1.png' /> 而不是图像.有没有办法禁止它的编码呢? 解决方法你可以使用@ Html.Raw(r)而不是@(r).(编辑:鄂州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 304未修改静态文件
- asp.net core标签助手的高级用法TagHelper+Form
- .net – 加密ApplicationServices ConnectionString
- asp.net实现文件下载的代码
- asp.net – MS Chart控件创建的临时文件应该放在哪里?
- 具有多个ASP.NET Web应用程序的Visual Studio解决方案
- asp.net中MVC借助Iframe实现无刷新上传文件实例
- asp.net-mvc – 奇怪的错误w / NinjectValidatorFactory更新
- asp.net – Tridion分析和个性化错误:用户不能为空.请确保
- ASP.NET:将内容注入所有Response流