PC Review


Reply
Thread Tools Rating: Thread Rating: 4 votes, 1.00 average.

Dynamic ASP style sheet not working

 
 
Suba
Guest
Posts: n/a
 
      5th Mar 2008
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
 
Reply With Quote
 
 
 
 
Mufaka
Guest
Posts: n/a
 
      5th Mar 2008
Suba wrote:
> 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

link1.Attributes["text"] = "text/css";

should be

link1.Attributes["type"] = "text/css";

You may have to add your attributes in the following manner as well:

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

And make sure that your dynamic style sheet is setting the right
content-type.
 
Reply With Quote
 
Suba
Guest
Posts: n/a
 
      6th Mar 2008

I modified the code.....but still not working.............

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

how to make sure my dynamic style sheet is setting the correct content
type....its a simple asp page...............

link1.Attributes.Add("type", "text/css"); --> i thought this takes care of
setting the correct content type..............

"Mufaka" wrote:

> Suba wrote:
> > 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

> link1.Attributes["text"] = "text/css";
>
> should be
>
> link1.Attributes["type"] = "text/css";
>
> You may have to add your attributes in the following manner as well:
>
> link1.Attributes.Add("rel", "stylesheet");
> link1.Attributes.Add("type", "text/css");
>
> And make sure that your dynamic style sheet is setting the right
> content-type.
>

 
Reply With Quote
 
Mufaka
Guest
Posts: n/a
 
      6th Mar 2008
That tells the browser that the link content type should be text/css. I
was referring to your dynamic css page. You may need something like
Response.ContentType = "text/css" in that page.

Beyond that, I am not sure why it wouldn't work. You can try pointing
your web browser at your dynamic css page and see if what you get is
what you expect.

Suba wrote:
> I modified the code.....but still not working.............
>
> link1.Attributes.Add("rel", "stylesheet");
> link1.Attributes.Add("type", "text/css");
>
> how to make sure my dynamic style sheet is setting the correct content
> type....its a simple asp page...............
>
> link1.Attributes.Add("type", "text/css"); --> i thought this takes care of
> setting the correct content type..............
>

<snip>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic ASPX Style Sheet not Render in FireFox? coconet Microsoft ASP .NET 6 6th Mar 2008 02:37 PM
Dynamic style sheet link. David W Microsoft ASP .NET 2 31st Oct 2007 01:59 AM
Style Sheet stopped working =?Utf-8?B?dGNhcnA=?= Microsoft Frontpage 2 9th Mar 2006 09:42 AM
Dynamic Web Template and Linked CSS Style Sheet =?Utf-8?B?RXh0cmFQaWxvdA==?= Microsoft Frontpage 2 14th Sep 2005 05:53 PM
Re: Style Sheet Links does not Update Dynamic Templates (.dwt's) Stefan B Rusynko Microsoft Frontpage 0 27th Aug 2004 11:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:13 PM.