Using a css style sheet

John

Junior Contributor
Joined
Feb 3, 2002
Messages
256
Location
The Inner Loop
Hi,
I am using the ASPNETPortal from the ASP.NET Starter Kits as the starting point for a site I'm building. This project makes use of a css style sheet so all the aspx files have the following line in the HTML view of the page inside the <head> </head> tags:
Code:
<link rel="stylesheet" href='<%= Global.GetApplicationPath(Request) [b]&[/b] "/ASPNETPortal.css" %>' type="text/css">

For some reason when you change anything on the page in design view the IDE automatically changes it to this:
Code:
<link rel="stylesheet" href='<%= Global.GetApplicationPath(Request) [b]&[/b] "/ASPNETPortal.css" %>' type="text/css">

Then when you run the project it errors on that line. Now I know I can simply change it to this:
Code:
<link href='/PortalVBVS/ASPNETPortal.css' type="text/css" rel="stylesheet">

The point being that it becomes less portable doing it this way. I'm just wondering if anyone knows how I can get the IDE to stop changing this thing on me all the time.

Thanks,
John
 
There is probably a post-build script in the project file, you can find it and disable or alter it, or you can make the aspx file read-only until such time that you want to change it.
 
I don't know what a post-build script is. Where might I find this?

Also, this is happening in the IDE, not when I run the project. As soon as I change something on any of the aspx files in design view I can immediately click HTML to view the HTML code and it has already changed.
 
I changed it to use String.Concat instead of the concatenation operator:
Code:
<link href='<%= String.Concat(Global.GetApplicationPath(Request), "/ASPNETPortal.css") %>' type=text/css rel=stylesheet>
All is well now.

Thanks,
John
 
Out of curiousity, could you not also have simply inserted a literal control?

Code:
<head>
  <ASP:Literal ID="litCSSLink" RunAt="server" />
</head>

And somewhere else

Code:
litCSSLink.Text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" & Global.GetApplicationPath(Request) & "/ASPNETPortal.css" />"

Just wondering because I've gotten the impression doing the <%=myVar%> style was not the preferred way of doing things anymore as of .NET. Is it still considered OK in certain situations such as this?

Oh, and it occurs to me...why concat at all?

Code:
<link rel="stylesheet" href='<%= Global.GetApplicationPath(Request) %>/ASPNETPortal.css' type="text/css">

Shouldn't this produce the same result?
 
Back
Top