Masterpages css problems


G

Guest

Im having a masterpages meltdown. I previously did an app where the
masterpage and aspx pages were in the same folder, no problems. In a second
app, for esthetics, I put the masterpage in the root and the aspx pages in a
/Pages folder. If I hard-code the css <LINK statement in the masterpage the
classes are used as expected. However, in this app the .css (and other stuff)
is in user-specific folders, so I need to perform this programatically; Im
using the methods below from
http://pluralsight.com/blogs/ted/archive/2005/08/31/14437.aspx

No matter what I could think of to pass as the stylesheet
("./Images/User1/xx.css", and any variation of it), the css classes (which
for right now just control fonts) arent used. I wound up doing View Sources
on the html, and the only way to get the exact same href as when I hardcoded
it required me to change
link1.Href = page.ResolveUrl(stylesheet);
to
link1.Href = "."+page.ResolveUrl(stylesheet);
But it didnt matter, even when I generated equivalent html the
classes werent used.
Any help would be massively appreciated, Ive beaten my head on this way to
long.

Thanks, Mark
public void AddLinkedStyleSheet(Page page, string stylesheet)
{
HtmlLink link1 = new HtmlLink();
link1.Href = page.ResolveUrl(stylesheet);
link1.Attributes["text"] = "text/css";
link1.Attributes["rel"] = "stylesheet";

page.Header.Controls.Add(link1);
}
public void AddLinkedStyleSheet(MasterPage page, string stylesheet)
{
this.AddLinkedStyleSheet(page.Page, stylesheet);
}
 
Ad

Advertisements

A

apathetic

MarkAurit said:
No matter what I could think of to pass as the stylesheet
("./Images/User1/xx.css", and any variation of it),

Are you passing ~ as part of the CSS path? E.g.:

AddLinkedStyleSheet( page, "~/css/xxx.css" );

Your question is a little confusing. What is the HTML output for each
of the variations you've tried?

apathetic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top