Solved

Tilda is not working in URL paths

Posted on 2006-11-16
11
1,151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

729 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