Use of Tilde (~) and <LINK>

G

Guest

I just learned about the wonderful ~ in paths in ASP.NET which allows me to reference the APPLICATION root instead of the IIS docroot. Love it! I'm finding that I can use ~ in many places as long as the control in which it's used is set to runat="server". It's very handy.

Here's the problem. I have
<link rel="STYLESHEET" type="text/css" href="/Shared/CSS/Global.css" /
on every page of the site. I REALLY want to be able to locate the href of this link using the ~ so that it's relative to the application root rather than the IIS docroot. But it doesn't seem like there's any way to do that.

Ideas

Ale
 
S

Scott Mitchell [MVP]

Alex said:
I just learned about the wonderful ~ in paths in ASP.NET which allows me to reference the APPLICATION root instead of the IIS docroot. Love it! I'm finding that I can use ~ in many places as long as the control in which it's used is set to runat="server". It's very handy.

Here's the problem. I have
<link rel="STYLESHEET" type="text/css" href="/Shared/CSS/Global.css" />
on every page of the site. I REALLY want to be able to locate the href of this link using the ~ so that it's relative to the application root rather than the IIS docroot. But it doesn't seem like there's any way to do that.

Ideas?

How about putting:

<asp:LiteralControl runat="server" id="linkLit" />

The in Page_Load putting:

linkLit.Text = String.Format("<link rel=""STYLESHEET"" type=""text/css""
href=""{0}"" />", Page.ResolveUrl("~/Global.css (or whatever)"))


hth

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
G

Guest

Yeah, that's what I'm doin'. Don't love it but it does the job. Thanks

----- Scott Mitchell [MVP] wrote: ----

Alex Maghen wrote
I just learned about the wonderful ~ in paths in ASP.NET which allows me to reference the APPLICATION root instead of the IIS docroot. Love it! I'm finding that I can use ~ in many places as long as the control in which it's used is set to runat="server". It's very handy.

How about putting

<asp:LiteralControl runat="server" id="linkLit" /

The in Page_Load putting

linkLit.Text = String.Format("<link rel=""STYLESHEET"" type=""text/css""
href=""{0}"" />", Page.ResolveUrl("~/Global.css (or whatever)")


ht

--

Scott Mitchel
(e-mail address removed)
http://www.4GuysFromRolla.co
http://www.ASPFAQs.co
http://www.ASPMessageboard.co

* When you think ASP, think 4GuysFromRolla.com
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top