asp.net-mvc – mvc razor @helper可以返回非编码标签吗?
发布时间:2021-01-11 11:54:18 所属栏目: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-mvc – 在MVC4中绑定的正确方法
- asp.net – 在SQL Server中将日期转换为刻度
- asp.net-core – 加密ASP.Net Core中的连接字符串和其他配置
- asp.net中利用Jquery+Ajax+Json实现无刷新分页的实例代码
- asp.net – visual studio 2017调试无法启动程序无效指针
- asp.net-mvc – 使用IIS7.5将网站中的URL绑定到另一个网站控
- 在ASP.Net中防止SQL注入
- asp.net-mvc – KendoUI网格显示总记录数
- asp.net-mvc – Asp.Net MVC CSLA DDD可能
- ASP.NET 清除模式窗口数据缓存的操作方式
推荐文章
站长推荐
- asp.net-mvc – 为一个MVC视图使用两个强类型模型
- asp.net-mvc – 在ClaimsIdentity上,BootstrapCo
- asp.net – 按钮属性: – commandName和Command
- asp.net中XML如何做增删改查操作
- 什么是使用aspnet_compiler.exe预编译ASP.NET项目
- asp.net-mvc – MVC 5 OWIN登录声明和Antiforger
- Asp.net mvc验证用户登录之Forms实现详解
- ASP.NET网址MAX_PATH限制
- 如何使用ASP.NET MVC Web API OData链接到Razor中
- asp.net-mvc – ASP.Net MVC中的自我AJAX更新部分
热点阅读