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

R

Richard Coltrane

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
 
R

Richard Coltrane

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">
 
G

Graeme Bradbury

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top