Solved

Tilda is not working in URL paths

Posted on 2006-11-16
11
1,145 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
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.…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

13 Experts available now in Live!

Get 1:1 Help Now