471,109 Members | 1,009 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,109 software developers and data experts.

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 2444
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.