asp.net链接标记语法错误

时间:2021-03-03 23:02:27

I am trying to load stylesheet dynamically from folder, but currently, it isn't working:

我试图从文件夹动态加载样式表,但目前,它无法正常工作:

<head id="Head1" runat="server">
     <link  type="text/css" rel="styleSheet"  href="http://www.domain.com/users/'<%= UserNameVar%>'/styleSheet.css" />
</head>

UserNameVar contains string data.

UserNameVar包含字符串数据。

Edit: This is the output when i upload it to server. but it is not loading

编辑:这是我上传到服务器时的输出。但它没有加载

<link type="text/css" rel="styleSheet" href="http://www.domain.com/users/&#39;&lt;%= UserNameVar%>&#39;/styleSheet.css" /></head>

1 个解决方案

#1


2  

Put all href value in <%= and %>

将所有href值放在<%=和%>中

Try this:

尝试这个:

<head id="Head1" runat="server">
     <link  type="text/css" rel="styleSheet"  href=<%= "http://www.domain.com/users/" + UserNameVar + "/styleSheet.css />" %>     
</head>

#1


2  

Put all href value in <%= and %>

将所有href值放在<%=和%>中

Try this:

尝试这个:

<head id="Head1" runat="server">
     <link  type="text/css" rel="styleSheet"  href=<%= "http://www.domain.com/users/" + UserNameVar + "/styleSheet.css />" %>     
</head>