Is this "correct" and I should be using some kind of SERVER side "link" control (if so where is it?) or is this a bug and you can't put a server output statement inside a quoted string or something wacky like that...
???
Opinions expressed are mine alone...
Unless I cut and pasted them from somewhere...or my wife told me to have them...
<%
var x = Request.ApplicationPath;
Response.Write(x); //Use this to see O/P
%>
Also i suppose this is your masterpage, now you cannot just display the masterpage, and check the title in your childpage, what title are you using there?
Unfortunately that's exactly what I'm trying to do get to the parent apps content file... I just wanted an easy way to reference the root applications styles rather like sharepoint does with its themes and webconfigs do with inheriting from the parent if they
exist... I guess this may not be the best way to do it and if master pages use the folder in links without needing a run at server then this probably explains the behaviour and its probably not a bug... Will experiment and try to bit or out.
Opinions expressed are mine alone...
Unless I cut and pasted them from somewhere...or my wife told me to have them...
Well "allowed" or not it does actually work (although VS complains "not found" with green underline) it actually generates the correct HTML that allows the site to reference its parents stylesheets and images...
I guess I should have tried that, but because of not being that familiar with MasterPages, I guess I thought that ~ would only work (as it says in the documentation on the MS site) in server side controls and code (but obviously LINK in MasterPage is a special
case)...
Interestingly using an image tag in the same manner is inconsistent with this:
<img src="~\..\etc
renders a missing link.
However, inconsistent or not, if I just add runatserver it does what I want so its not all so terribly horrible...
<img runat="server" src="~\..\etc
Well done you!
Opinions expressed are mine alone...
Unless I cut and pasted them from somewhere...or my wife told me to have them...
smerlon
Member
13 Points
38 Posts
MasterPages - Is this a bug or am I missing something?
Apr 17, 2012 04:43 AM|LINK
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-AU" xml:lang="en-AU"> <head runat="server"> <meta http-equiv="Content-Script-Type" content="text/javascript"/> <link href="<%= Request.ApplicationPath%>/../Content/Site.css" rel="stylesheet" type="text/css" />Renders like this:
Is this "correct" and I should be using some kind of SERVER side "link" control (if so where is it?) or is this a bug and you can't put a server output statement inside a quoted string or something wacky like that...
???
Unless I cut and pasted them from somewhere...or my wife told me to have them...
nijhawan.sau...
All-Star
16430 Points
3173 Posts
Re: MasterPages - Is this a bug or am I missing something?
Apr 17, 2012 05:00 AM|LINK
You can surely do this:
<% var x = Request.ApplicationPath; Response.Write(x); //Use this to see O/P %>Also i suppose this is your masterpage, now you cannot just display the masterpage, and check the title in your childpage, what title are you using there?
smerlon
Member
13 Points
38 Posts
Re: MasterPages - Is this a bug or am I missing something?
Apr 17, 2012 05:04 AM|LINK
Sorry I should have been more explicit in what the problem was (but I couldn't figure out how to highlight in code stuff)
<link href="<%= Request.ApplicationPath%>/../Content/Site.css" rel="stylesheet" type="text/css" />
outputs like this:
Yes its a MasterPage, and this:
<img alt="Logo Crest" src="<%=Request.ApplicationPath%>/../Content/images/Logo_inline.png" style="float:left;padding-right:20px;" />works as you'd expect... and the path is correctly relative.
Is there a bug in Masterpages, or is there something special in the <head> or <link> tags that I'm not aware of?
Unless I cut and pasted them from somewhere...or my wife told me to have them...
Dave Sussman
All-Star
37716 Points
5005 Posts
ASPInsiders
MVP
Re: MasterPages - Is this a bug or am I missing something?
Apr 17, 2012 08:14 AM|LINK
You should just be able to use ~ to represent the app root. Eg:
<link href="~/../Content/Site.css" rel="stylesheet" type="text/css" />
Although this would point to a file outside the root, which isn't allowed. This
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
would point at the Content folder underneath the root.
smerlon
Member
13 Points
38 Posts
Re: MasterPages - Is this a bug or am I missing something?
Apr 17, 2012 10:47 PM|LINK
Unless I cut and pasted them from somewhere...or my wife told me to have them...
smerlon
Member
13 Points
38 Posts
Re: MasterPages - Is this a bug or am I missing something?
Apr 18, 2012 12:04 AM|LINK
Well "allowed" or not it does actually work (although VS complains "not found" with green underline) it actually generates the correct HTML that allows the site to reference its parents stylesheets and images...
I guess I should have tried that, but because of not being that familiar with MasterPages, I guess I thought that ~ would only work (as it says in the documentation on the MS site) in server side controls and code (but obviously LINK in MasterPage is a special case)...
Interestingly using an image tag in the same manner is inconsistent with this:
renders a missing link.
However, inconsistent or not, if I just add runatserver it does what I want so its not all so terribly horrible...
Well done you!
Unless I cut and pasted them from somewhere...or my wife told me to have them...