tags:

views:

48

answers:

2

In my aspx I have this line:

<link href="<%= Request.ApplicationPath %>/css/ma/screen-ma.css"        rel="Stylesheet"type="text/css" media="screen" />

which renders as:

<link href="/XFormPortal/css/ma/screen-ma.css"        rel="Stylesheet"type="text/css" media="screen" /> 

That seems correct, right?

Then i change a single character, lets say add a space between the rel and the type attribute, so now I have the following:

<link href="<%= Request.ApplicationPath %>/css/ma/screen-ma.css"        rel="Stylesheet" type="text/css" media="screen" />

Which now rendes as:

<link href="&lt;%= Request.ApplicationPath %>/css/ma/screen-ma.css" rel="Stylesheet" type="text/css" media="screen" /> 

Okay, what just happend here? The inline code tag is suddenly ignored and written out as text? Because of a single space?

Can anyone explain this?

+3  A: 

I would suggest it has something to do with the order in which expressions are parsed by the precompiler... specifically, I suspect that the omission of the space in your first example causes a particular regular expression match to fail, and you essentially escape correct parsing. Use single quotes around your href tag instead.

PjL
That made no difference. Good suggestion though!
Silas Hansen
Interesting.. I've also found that it doesn't matter which space you omit, as long as you omit one ;-) ... which led me to:<link href=<%="\""+Request.ApplicationPath%>/css" rel="Stylesheet" type="text/css" media="screen"/>(include the opening quote in your inline emitter.
PjL
That seems to work! Thanks for taking the time to shed some light on this issue which I hope will be a help for other people in the future.
Silas Hansen
+1  A: 
<link href=<%="\""+Request.ApplicationPath%>/css" rel="Stylesheet" type="text/css" media="screen"/>
PjL
this should also be equivalent... <link href="~/css" .../>
PjL