Solved

Tilda is not working in URL paths

Posted on 2006-11-16
11
1,153 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
Independent Software Vendors: 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

627 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