468,720 Members | 1,731 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

C# - Cant dynamically set url of css file but can in vb.net??

Hi There,

Does anyone know iwhy I can do this in VB.Net:

<link rel="stylesheet" href="<%=Global_asax.GetApplicationPath()
%>styles/main.css" type="text/css">

in the header of an aspx page and not have a problem. i.e it converts nicely
but when i do it in c# it always converts the first "<" to ="&lt and thus
becomes

<link rel="stylesheet" href="&lt;% = MaranuiGlobal.GetApplicationPath()
%>styles/main.css" type="text/css" />

which in turn is not interpreted by the asp.net engine. Note this doesn;t
happen in the source file and is not a problem with the designer. It occurs
at runtime.
And yet as with vb.net this kind of statement in interpreted correctly for
all other tags including refs to javascript files. Its just with CSS/link
tags???

Thanks


Aug 24 '07 #1
2 2403
Please ignore difference in method name in the second statement:

<link rel="stylesheet" href="="&lt;%=Global_asax.GetApplicationPath()

I copy pasted the wrong code. This is not the problem.

Thanks
%>styles/main.css" type="text/css">
"Richard Coltrane" <rc@spamsux.comwrote in message
news:eM**************@TK2MSFTNGP05.phx.gbl...
Hi There,

Does anyone know iwhy I can do this in VB.Net:

<link rel="stylesheet" href="<%=Global_asax.GetApplicationPath()
%>styles/main.css" type="text/css">

in the header of an aspx page and not have a problem. i.e it converts
nicely but when i do it in c# it always converts the first "<" to ="&lt
and thus becomes

<link rel="stylesheet" href="&lt;% = MaranuiGlobal.GetApplicationPath()
%>styles/main.css" type="text/css" />

which in turn is not interpreted by the asp.net engine. Note this doesn;t
happen in the source file and is not a problem with the designer. It
occurs at runtime.
And yet as with vb.net this kind of statement in interpreted correctly for
all other tags including refs to javascript files. Its just with CSS/link
tags???

Thanks


Aug 24 '07 #2
>>
> <link rel="stylesheet" href="<%=Global_asax.GetApplicationPath()
%>styles/main.css" type="text/css">

Try using ResolveClientUrl instead ie.
<link rel="stylesheet" href="<%=ResolveClientUrl("~/styles/main.css")%>"
type="text/css">

Aug 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by max | last post: by
1 post views Thread by archana | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Oskars | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.