ASP.NET MVC内标签不以&lt工作;联系HREF> [英] ASP.NET MVC inline tags not working with <link href>

查看:104
本文介绍了ASP.NET MVC内标签不以&lt工作;联系HREF>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每一次我把一个内嵌标签上的链接的href属性它在某种程度上得到自动连接codeD。这是ASP.NET的默认行为?我怎么能动态设置使用code中的href属性?这是MVC BTW。

Every time I put an inline tag on the link's href attribute it somehow gets auto-encoded. Is this ASP.NET's default behavior? How can I dynamically set the Href attribute using code? This is in MVC btw.

试图像这样

<link href="<%: Link.Content.Jquery_css %>" rel="stylesheet" type="text/css" />

而致本(什么都没有改变)

which rendered this (nothing changed)

<link href="<%: Link.Content.Jquery_css %>" rel="stylesheet" type="text/css" />

<link href="<%= Link.Content.Jquery_css %> rel="stylesheet" type="text/css" />

它生产的(我不记得确切的数字,但似乎支架,百分号,等号是连接codeD链接格式)

which produced this (I couldn't remember the exact numbers, but it seems the bracket-percent-equals was encoded to link format)

<link href="/View/Shared%25Link.Content.Jquery_css%25" %>" rel="stylesheet" type="text/css" />

Link.Content.Jquery_css 是使用T4MVC制成包含链接一个强类型的字符串。

Link.Content.Jquery_css is a strongly typed string containing the link made using T4MVC.

用户互动,增加信息:我用ASP.NET MVC 2,在.NET 4和测试在Firefox

Add'l info: I used ASP.NET MVC 2, in .NET 4 and testing in Firefox.

推荐答案

这是越来越因为标签的使用(&LT的自动连接codeD;%:&GT; )。如果你不想要的网址是恩codeD,请使用以下内容:

It's getting auto-encoded because of the tag your using (<%: %>). If you don't want the URL to be Encoded, use the following:

<link href="<%= Link.Content.Jquery_css %>" rel="stylesheet" type="text/css" />

这篇关于ASP.NET MVC内标签不以&lt工作;联系HREF&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆