Solved

Tilda is not working in URL paths

Posted on 2006-11-16
11
1,150 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 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