首页 新闻 会员 周边

asp.net变量的问题

0
悬赏园豆:5 [已解决问题] 解决于 2009-09-11 00:16

想请教下各位朋友, 你们在aspx页面用<%=变量名%>   的时候 有没有遇到 在html页面解析后 <变 成 &lt; 了 用<link href="<%= tt %>" rel="stylesheet" type="text/css" /> 就出错 源文件就变成 <link href="&lt;%= tt %>" rel="stylesheet" type="text/css" />   你们知道为什么不 

ruonanxiao的主页 ruonanxiao | 初学一级 | 园豆:6
提问于:2009-09-10 15:14
< >
分享
最佳答案
0

这样的代码应该没有问题,另外你也可以试试单引号

<head runat="server">
<title>UrlToHtml</title>

<script type="text/C#" runat="server">
public string tt
= "/Resource/style/base.css";
public string tt2
= "/Resource/style/demos.css";
</script>

<link href="<%= tt %>" rel="stylesheet" type="text/css" />
<link href='<%= tt2 %>
' rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
UrlToHtml is Suceess!
<br />
<%=tt %><br />
<%=tt2 %>
</div>
</form>
</body>
</html>

UrlToHtml is Suceess!
/Resource/style/base.css
/Resource/style/demos.css

另外,人也可以参考一下这里
动态加载css的实现思路
http://www.cnblogs.com/downmoon/archive/2009/07/17/1525516.html

 

收获园豆:5
邀月 | 高人七级 |园豆:25475 | 2009-09-10 16:00
谢谢
ruonanxiao | 园豆:6 (初学一级) | 2009-09-11 00:15
分很少 谢谢关注
ruonanxiao | 园豆:6 (初学一级) | 2009-09-11 00:16
其他回答(2)
0

一般的我只要是绑定到href 、一些属性上的。我都是用 ‘<%= tt %> ’

邢少 | 园豆:10926 (专家六级) | 2009-09-10 16:01
0

以前1.1 好像出现过  2.0 没发现

Mr雨 | 园豆:1199 (小虾三级) | 2009-09-10 20:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册