467,885 Members | 1,355 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,885 developers. It's quick & easy.

Dynamic ASP style sheet not working

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
Mar 5 '08 #1
  • viewed: 2686
Share:
3 Replies
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.
Mar 5 '08 #2

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.
Mar 6 '08 #3
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>
Mar 6 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Abraham Luna | last post: by
1 post views Thread by Andrew Poulos | last post: by
5 posts views Thread by Gary | last post: by
3 posts views Thread by Capricorn | last post: by
2 posts views Thread by JWL | last post: by
reply views Thread by Eniac | last post: by
2 posts views Thread by David W | last post: by
4 posts views Thread by coconet | last post: by
5 posts views Thread by =?Utf-8?B?SmVycnkgQw==?= | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.