asp.net-mvc – mvc razor @helper可以返回非编码标签吗?
发布时间:2021-01-11 12:36:34  所属栏目: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-4 – .net 4.5 ASP.Net web API JSONP支持
 - .Net 更容易的使用配置文件 SuperConfig
 - ASP.NET中TextBox使用Ajax控件显示日期不全的问题解决方法
 - asp.net – 防止XSS(跨站脚本)
 - asp.net-mvc – 从控制器重定向初始化不工作
 - asp.net-mvc – asp.net mvc – string或int的路由(即/ typ
 - 如何在asp.net用户控件中使用jQuery ajax?
 - 增加ASP.NET站点的executionTimeout和maxRequestLength是否
 - asp.net-mvc – 带有lambda表达式的ASP.net MVC Action URL
 - ASP.NET拒绝访问该路径
 
推荐文章
            站长推荐
            
        热点阅读
            