473,245 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 software developers and data experts.

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
3 2915
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to....
1
by: Andrew Poulos | last post by:
I'm using the following to dynamically add a style sheet with larger font sizes: if (document.createStyleSheet) { document.createStyleSheet("extras/styles_large.css"); } else { var oStyle =...
5
by: Gary | last post by:
I am not sure what group to post this to but here goes. I am dynamically creating a web page using perl. I grabbed a style sheet from a free site and hacked it to look the way I wanted. I then...
3
by: Capricorn | last post by:
Hi, can anybody tell me how you can create a new stylesheet inside a (X)HTML page with JavaScript and Firefox, if the stylesheet is only available as a variable value, like: var CSSStyle =...
2
by: JWL | last post by:
Hi I need to create a bunch of sites with slightly dynamic CSS. Basically, all the image paths in the CSS need to be dynamic, depending on the values of certain ASP variables. I can think of...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
2
by: David W | last post by:
I need to include a style sheet link in the aspx page based on what user they are. Basically this functionality, but using code behind. Any idea how to change this line to code behind? This...
4
by: coconet | last post by:
Server is Win2K3/IIS6. I have an ASPX page with this in the <headtag: <link rel="stylesheet" type="text/css" href="<% Response.Write( "http://" + Request.ServerVariables.ToString() +...
5
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a machine running IIS 6.0. I just replaced the web.config and several aspx pages in the application and now the style sheets are not working. the images from the themes work but not the css...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.