Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Dynamic ASPX Style Sheet not Render in FireFox?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
coconet - 29 Dec 2007 06:34 GMT
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.
Milosz Skalecki [MCAD] - 30 Dec 2007 01:21 GMT
Howdy,

I reckon it should be:

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

Regards
Signature

Milosz

> Server is Win2K3/IIS6.
>
[quoted text clipped - 24 lines]
>
> Thanks.
Jialiang Ge [MSFT] - 31 Dec 2007 03:19 GMT
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 (jialge@online.microsoft.com, 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.
Jialiang Ge [MSFT] - 04 Jan 2008 02:58 GMT
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  (jialge@online.microsoft.com, 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.
Suba - 06 Mar 2008 14:37 GMT
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

> Hello coconet
>
[quoted text clipped - 43 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
gchq - 12 Feb 2008 04:15 GMT
> Server is Win2K3/IIS6.
>
[quoted text clipped - 24 lines]
>
> 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
Suba - 06 Mar 2008 14:34 GMT
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...........

> > Server is Win2K3/IIS6.
> >
[quoted text clipped - 31 lines]
>         Response.Clear()
>         Response.BufferOutput = True

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.