473,659 Members | 2,944 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing CSS sheets from Code

I want to have a single CSS style sheet control the look of my whole asp.net
application but I need to set the values in this CSS from code in the start
page as the CSS values will be stored in a data base.

First, is this possible?

Since CSS is plain text I could manipulate it all with string string
functions in code, BUT, are there any classes or functions that make it
easier to affect CSS parameters at run time?

Thank you in Advance for any Help,
T. Wong
Mar 10 '06 #1
5 1448
Yes and no.

The issue lies in the fact that CSS is a client side script while you are
changing on server side. You can certainly dynamically output some styles,
which will solve your issue (as the cascade defaults on using page styles
first over the stylesheet), but you would be better served to create
different style sheets for different "themes" and change the stylesheet link.

NOTE: This is easier in .NET 2.0 than 1.x.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** ************
Think Outside the Box!
*************** ************
"T. Wong" wrote:
I want to have a single CSS style sheet control the look of my whole asp.net
application but I need to set the values in this CSS from code in the start
page as the CSS values will be stored in a data base.

First, is this possible?

Since CSS is plain text I could manipulate it all with string string
functions in code, BUT, are there any classes or functions that make it
easier to affect CSS parameters at run time?

Thank you in Advance for any Help,
T. Wong

Mar 10 '06 #2
hmmm... how can I change the Stylesheet link from my server code?

"Cowboy (Gregory A. Beamer) - MVP" <No************ @comcast.netNoS pamM> wrote
in message news:35******** *************** ***********@mic rosoft.com...
Yes and no.

The issue lies in the fact that CSS is a client side script while you are
changing on server side. You can certainly dynamically output some styles,
which will solve your issue (as the cascade defaults on using page styles
first over the stylesheet), but you would be better served to create
different style sheets for different "themes" and change the stylesheet
link.

NOTE: This is easier in .NET 2.0 than 1.x.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** ************
Think Outside the Box!
*************** ************
"T. Wong" wrote:
I want to have a single CSS style sheet control the look of my whole
asp.net
application but I need to set the values in this CSS from code in the
start
page as the CSS values will be stored in a data base.

First, is this possible?

Since CSS is plain text I could manipulate it all with string string
functions in code, BUT, are there any classes or functions that make it
easier to affect CSS parameters at run time?

Thank you in Advance for any Help,
T. Wong

Mar 10 '06 #3
I did not make myself clear...

I want to create new classes in Styles.css from code on the fly. My
question was: can this be done.
T.Wong

"Cowboy (Gregory A. Beamer) - MVP" <No************ @comcast.netNoS pamM> wrote
in message news:35******** *************** ***********@mic rosoft.com...
Yes and no.

The issue lies in the fact that CSS is a client side script while you are
changing on server side. You can certainly dynamically output some styles,
which will solve your issue (as the cascade defaults on using page styles
first over the stylesheet), but you would be better served to create
different style sheets for different "themes" and change the stylesheet
link.

NOTE: This is easier in .NET 2.0 than 1.x.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** ************
Think Outside the Box!
*************** ************
"T. Wong" wrote:
I want to have a single CSS style sheet control the look of my whole
asp.net
application but I need to set the values in this CSS from code in the
start
page as the CSS values will be stored in a data base.

First, is this possible?

Since CSS is plain text I could manipulate it all with string string
functions in code, BUT, are there any classes or functions that make it
easier to affect CSS parameters at run time?

Thank you in Advance for any Help,
T. Wong

Mar 11 '06 #4
Use System.IO to write to style.css.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"T. Wong" <TW***@nospamme excite.com> wrote in message news:uW******** ******@TK2MSFTN GP11.phx.gbl...
I did not make myself clear...

I want to create new classes in Styles.css from code on the fly. My question was: can this be
done.
T.Wong

"Cowboy (Gregory A. Beamer) - MVP" <No************ @comcast.netNoS pamM> wrote in message
news:35******** *************** ***********@mic rosoft.com...
Yes and no.

The issue lies in the fact that CSS is a client side script while you are
changing on server side. You can certainly dynamically output some styles,
which will solve your issue (as the cascade defaults on using page styles
first over the stylesheet), but you would be better served to create
different style sheets for different "themes" and change the stylesheet link.

NOTE: This is easier in .NET 2.0 than 1.x.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** ************
Think Outside the Box!
*************** ************
"T. Wong" wrote:
I want to have a single CSS style sheet control the look of my whole asp.net
application but I need to set the values in this CSS from code in the start
page as the CSS values will be stored in a data base.

First, is this possible?

Since CSS is plain text I could manipulate it all with string string
functions in code, BUT, are there any classes or functions that make it
easier to affect CSS parameters at run time?

Thank you in Advance for any Help,
T. Wong


Mar 11 '06 #5
On Fri, 10 Mar 2006 16:34:32 -0800, T. Wong wrote:
I did not make myself clear...

I want to create new classes in Styles.css from code on the fly. My
question was: can this be done.


While it CAN be done, the question is, SHOULD it be done?

One issue is that CSS pages are oftech cached. If you change or update
them dynamically, your client web browser will likely ignore any new
changes and use their cached versions.

You *COULD* dynamically generate new CSS pages on the fly, either by
directly writing them to disk or by using an HTTPModule (if you map css
files to be handled by aspnet). But, again, this sort of dereats the
purpose of CSS, since you're going to have a ton of cached files sitting
around.

If this is really that important, you would be better off simply
dynamically generating a "<style>" section in your web page to include your
dynamic CSS.
Mar 11 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4307
by: Jeremy | last post by:
Hi, I have an asp page that is returning data from a database. Sometimes this data is quite a few rows long. Problem is the customer (blah) wants to be able to print this data and wants a header printed on every page. I figured this one out using style sheets and a little something like this (in case anyone wants to use this): br.page { page-break-before: always; }
4
18238
by: sunilkeswani | last post by:
I need help with exporting data from 2 access tables, into 2 existing spreadsheets in a single Excel file. Currently, I am using this code: DoCmd.TransferSpreadsheet acExport, 8, "Table1", "D:\Test.xls", True
2
1326
by: Terry | last post by:
I'm trying to change styles sheets on a per user basis. I was able to do this on the client using DOM, but how can I do this using the code behind page in the Load Page sub? I have a place that I save the user's preference for style (whihc style sheet they prefer to use), but how do I dynamically load the style sheet from the server at page load time?
7
2245
by: Wim Roffil | last post by:
I have a simple webpage (without stylesheet) where I want to be able to switch some parts of the page off. I tried to do this by giving all the elements that should be switched off the class "dname" and then to call the javascript: document.classes.dname.style.display = "none"; This does not work. Can someone suggest me how I could get this to work?
15
3850
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px; margin-left: -400px; width: 800px; height: 26px"> <!-- CODE GOES HERE --> </div>
4
1802
by: Sam Carleton | last post by:
How do I change the CSS colors via JavaScript DOM? Let me explain... I am working on a Windows application (in C#) that displays some HTML. In one place the HTML is a status window. What happens is the static HTML page is embedded into the application. The static page displayed and then the C# code gets a hold of the HTML DOM from the web browser and updates what pieces need to be updated. What I need to do now is change the colors...
0
3471
by: acarrazco | last post by:
Hello, I am totaly new to VBA and I'm trying to modify a macro that was given to me but it doesn't seem to be working. I'm trying to extract data from three excel spreadsheets, put it into a combined one which creates a pivot table and sorts it into different fromats. Here is the code, can any body help? Sub Update_Land_Actuals() On Error Resume Next If InputBox("Enter password to continue", "Centex Homes") <> "***" Then Exit Sub...
1
1126
by: yvhsb | last post by:
Hi, I am using visual basic for the first time to edit a spreadsheet with some macros in it. I've managed to suss a few things, but what has really stumped me is the runtime error 9 message I have. By reading around it looks as though it is to do with the fact that I have inserted worksheets. What do I need to change to enable them to run? This is the thread. The highlighted in yellow line is this one: Sheets("Budget 1 - Directors...
6
9028
by: and1 | last post by:
hello .. hmm currently i'm working on vba in excel, apparently i use ADO to extract a table data from access to excel and it works fine. the problem is when i use the extracted data to create a chart using vba and it doesn't seem to display the data properly.. it is due to the text format when the data is extracted to excel.. how can i change it to number format when the table of data is extracted .. Here's the code: Dim cnt As New...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.