Solved

Tilda is not working in URL paths

Posted on 2006-11-16
11
1,146 Views
Last Modified: 2012-08-14
Hi,

I have put in the header of my page following links:
<head id="Head1">
    <title>Master</title>
    <link href="~/css/master.css" runat=server type="text/css" rel="stylesheet" />
    <link href="~/css/header.css" runat=server rel="stylesheet" type="text/css" />
</head>
I was expecting for tildas to get converted to actual path. This however did not happen. Here is what I get in source of my generated HTML:
<head id="Head1">
    <title>Master</title>
    <link href="~/css/master.css" type="text/css" rel="stylesheet"></link>
    <link href="~/css/header.css" rel="stylesheet" type="text/css"></link>
</head>

Please help.
0
Comment
Question by:transtoll2006
  • 2
  • 2
  • 2
  • +4
11 Comments
 
LVL 12

Expert Comment

by:sandip132
ID: 17961938
Have you tried this:

<link href="../css/master.css" runat=server type="text/css" rel="stylesheet" />
<link href="../css/header.css" runat=server rel="stylesheet" type="text/css" />
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 17961964
~ only gets converted when the containing object has a runat="Server" attribute.
0
 
LVL 6

Expert Comment

by:riyazthad
ID: 17962195
Hi transtoll2006,

Try this

<link href="./css/master.css" type="text/css" rel="stylesheet"></link>
<link href="./css/header.css" rel="stylesheet" type="text/css"></link>
0
 

Author Comment

by:transtoll2006
ID: 17962656
sandip132 & riyazthad:
The whole point of having ~ is to remove relative paths so neither of your suggestions is acceptable.

mrichmon:
As you can see in my example I already have runat=server attribute in place.

Any other ideas why it does not work?
0
 
LVL 4

Expert Comment

by:Sashi Rachabattula
ID: 17963326

This should work and no need Runat server tag
check for path of ur css file/folder

<link href="../css/master.css" type="text/css" rel="stylesheet" />
<link href="../css/header.css"  rel="stylesheet" type="text/css" />
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:Sashi Rachabattula
ID: 17963337
~ not working coz <link/> is not generic asp.net tag
0
 
LVL 6

Accepted Solution

by:
bigphuckinglizard earned 500 total points
ID: 17964104
you need to do

<head runat="server" id="head1">
    <link href="~/css/header.css" runat=server rel="stylesheet" type="text/css" />
</head>

to get that working...
0
 
LVL 6

Expert Comment

by:riyazthad
ID: 17965704
transtoll2006

your code is perfect. Nothing to do.

The problem I noticed in your generated HTML code. It is not actually converting. IT should be

<link href="css/master.css" type="text/css" rel="stylesheet"></link>
<link href="css/header.css" rel="stylesheet" type="text/css"></link>

Can you double check path is correct?
0
 

Author Comment

by:transtoll2006
ID: 17976280
Thank you igphuckinglizard, you've almost solved my problem and I will grant points to you anyway, the issues was having runat=server in my <head> tag.

There is however another problem. I have usercontrol placed on this page, which has a link to css file (own) too. It looks like this:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="menu.ascx.cs" Inherits="modules_menu" %>
    <link href="~/css/menu.css" runat=server type="text/css" rel="stylesheet" />
<div id="menu-wrap">
......

Generated html looks like this:
.......
            <div id="left">
                <link href="~/css/menu.css" type="text/css" rel="stylesheet"></link>
<div id="menu-wrap">
.......

As I can not have another <head> tag in my module what do I do to fix it? (I tried to add runat=server to div which contains my user control without any luck)

Thank you.
0
 
LVL 6

Expert Comment

by:bigphuckinglizard
ID: 17979823
you should avoid using linked stylesheets in user controls and look into the Page.Header.StyleSheet.CreateStyleRule method
0
 

Expert Comment

by:AndrewLundgren
ID: 23601282
BAM!

http://www.emadibrahim.com/2007/01/05/resolving-url-in-aspnet-using-tilda/
<link href=

"<%= ResolveClientUrl(~/css/menu.css) %>"

 type="text/css" rel="stylesheet" />

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now