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);
}
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);
}