Dynamic ASPX Style Sheet not Render in FireFox?

C

coconet

Server is Win2K3/IIS6.

I have an ASPX page with this in the <head> tag:

<link rel="stylesheet" type="text/css" href="<%
Response.Write( "http://" +
Request.ServerVariables["SERVER_NAME"].ToString() +
this.ResolveUrl("~") + "styles/styledefault.aspx"); %>" />



The style.aspx page looks like this:

body
{
background: #655A46 url('<% Response.Write(
this.ResolveUrl("~") + "media/"); %>bg.gif');
color: #543;
font: normal 62.5% "Lucida Sans Unicode",sans-serif;
}

....


The purpose is to have dynamically-changing styles. The page renders
fine with my external and dynamic style sheet in IE7, but in FireFox
the style appears to be ignored. What can I do to make this work?

Thanks.
 
M

Milosz Skalecki [MCAD]

Howdy,

I reckon it should be:

<link rel="stylesheet" type="text/css" href="<%=
ResolveClientUrl("~/styles/styledefault.aspx") %>" />

Regards
 
J

Jialiang Ge [MSFT]

Hello coconet

I have reproduced the issue with your code. I also tried Milosz's
suggestion, but the problem still exists.

Based on my test, the style sheet works as expected both in Firefox and IE
only when the href attribute of the link tag points to a css file. A
possible reason is that Firefox does not support a server page as a style
sheet. It depends on how Firefox is coded for it. Therefore, my suggestion
is to contact Firefox for further support. (e.g.
http://forums.mozillazine.org/viewforum.php?f=38)

Another workaround is to extract the styles in the apsx file into a
separate css file, and link to the css in your page. Hope it helps.

If you have any other concern or need anything else, please feel free to
let me know.

Happy New Year!

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hi coconet,

Would you mind letting me know the result of the suggestions? If you need
further assistance, feel free to let me know. I will be more than happy to
be of assistance.

Have a great day!

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

gchq

coconet said:
Server is Win2K3/IIS6.

I have an ASPX page with this in the <head> tag:

<link rel="stylesheet" type="text/css" href="<%
Response.Write( "http://" +
Request.ServerVariables["SERVER_NAME"].ToString() +
this.ResolveUrl("~") + "styles/styledefault.aspx"); %>" />



The style.aspx page looks like this:

body
{
background: #655A46 url('<% Response.Write(
this.ResolveUrl("~") + "media/"); %>bg.gif');
color: #543;
font: normal 62.5% "Lucida Sans Unicode",sans-serif;
}

....


The purpose is to have dynamically-changing styles. The page renders
fine with my external and dynamic style sheet in IE7, but in FireFox
the style appears to be ignored. What can I do to make this work?

Thanks.

Had the same problem - add this to the code behind (before the content) and
it will display OK in firefox

Response.ContentType = ("text/css")
Response.Clear()
Response.BufferOutput = True
 
S

Suba

Hi

I have a dynamic style sheet which is a asp page and am using <link> tag to
point to the asp page....i have the type and rel setup as given below....

link1.Attributes.Add("rel", "stylesheet");
link1.Attributes.Add("type", "text/css");
Page.Header.Controls.Add(link1);

i have added the following code to the asp page
Response.ContentType = ("text/css")
Response.Clear()
Response.BufferOutput = True

but still its not working..................none of the style attributes are
set in my page........ any idea why this is happening...........

gchq said:
coconet said:
Server is Win2K3/IIS6.

I have an ASPX page with this in the <head> tag:

<link rel="stylesheet" type="text/css" href="<%
Response.Write( "http://" +
Request.ServerVariables["SERVER_NAME"].ToString() +
this.ResolveUrl("~") + "styles/styledefault.aspx"); %>" />



The style.aspx page looks like this:

body
{
background: #655A46 url('<% Response.Write(
this.ResolveUrl("~") + "media/"); %>bg.gif');
color: #543;
font: normal 62.5% "Lucida Sans Unicode",sans-serif;
}

....


The purpose is to have dynamically-changing styles. The page renders
fine with my external and dynamic style sheet in IE7, but in FireFox
the style appears to be ignored. What can I do to make this work?

Thanks.

Had the same problem - add this to the code behind (before the content) and
it will display OK in firefox

Response.ContentType = ("text/css")
Response.Clear()
Response.BufferOutput = True
 
S

Suba

I am facing a similar problem

I am using a asp page to dynamically create a stylesheet

my asp page creates the following css element when i call the asp page my
typing the url in the browser. My asp page works fine............

body {
font-family : Arial, Helvetica, Sans-Serif, Verdana ;
margin : 0 ;
padding : 0 ;
}
..portal_nav {
margin-right : 30px ;
margin-top : 3px ;
}
#white_bar_1 {
height : 6px ;
width : 985px ;
background-color : #B32B3F ;
}
#white_bar_2 {
height : 8px ;
width : 985px ;
background-color : #B32B3F ;
}



my code goes like this for setting the stylesheet in ASP.NET master page

HtmlLink link1 = new HtmlLink();

if (null != Request.QueryString["CID"])
{
clientId = Request.QueryString["CID"];
Session["CID"] = clientId;
link1.Href = "~/NewClientPortal/stylesheet.asp?CID=" + clientId;
}
else if (Session["CID"] != null)
{
clientId = Session["CID"].ToString();
link1.Href = "~/NewClientPortal/stylesheet.asp?CID=" + clientId;
}
else
{
//Going to default CSS
}
link1.Attributes["text"] = "text/css";
link1.Attributes["rel"] = "stylesheet";
Page.Header.Controls.Add(link1);

my stylesheet setup in web.config is <pages theme=""> </page>

when i see the view source code when the page is rendered i see the <link>
element with the proper url............ but none of the style settings are
set to any of the controls................

Anyone has any idea....why this is happening.............need help badly
 

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

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top