asp.net-mvc – mvc razor @helper可以返回非编码标签吗?
发布时间:2020-12-15 20:15:01 所属栏目:asp.Net 来源:网络整理
导读:这是做的,但它基本上是我在做什么.我有一个这样的@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: theImag
这是做的,但它基本上是我在做什么.我有一个这样的@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).
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- IIS应用程序池_缓存回收
- asp.net-mvc – mvc4 new {vs new object {
- asp.net – 使用简单的ActionFilterAttribute运行时出错
- asp.net-mvc – 建议在开发期间使用nhibernate设置种子数据
- asp.net – IIS和线程
- ASP.net喜欢WPF MVVM棱镜中的基于表单的身份验证
- asp.net 多文件上传,兼容IE6/7/8,提供完整代码下载
- asp.net gridview复选框选择
- asp-classic – XP经典ASP上的IIS 5.1似乎处于单线程模式
- vbscript – 经典ASP 3.0从Recordset创建数组
推荐文章
站长推荐
- asp.net-mvc – 处理程序“dotless”在其模块列表
- asp.net – 根据IP地址限制对Elmah的访问
- asp.net – 使用EF4代码优先:如何在不丢失数据的
- asp.net – Silverlight中的多任务处理和多线程处
- asp.net – 页面控制
- asp.net – 在我的浏览器中测试Accept语言
- asp.net-mvc-2 – 查找要在ASP.NET MVC项目上使用
- asp.net – MVC ViewModel错误 – 没有为此对象定
- asp.net – 在jQuery对话框中的窗体中,MVC中通常
- asp.net-mvc-3 – 何时在Mvc3中使用ViewBag,View
热点阅读