Dynamically changing style definitions in page header

  • Thread starter Jason_SanDiego2006
  • Start date
J

Jason_SanDiego2006

Hello all,

Hang with me, I'm a little new.

I'm working on a web application in C# using ASP.NET 2.0

The goal of my application is to have pages whose styles can be dynamically
changed based on the logged-in user's saved preferences.

The user can define their own styles (font-size, font-family, color, etc.)
for the site's pages.

Instead of creating a bunch of .css files and dynamically linking to the
right one, I wanted to use a <style> section in each page's <head> section
that specifies the values to use for the selectors and their properties.

The values would be pulled from a database and written to this section, to
look like this:

<head>

<style type="text/css">
.testClass { color:purple;background-color:LightGreen; }
</style>

</head>

I have been able to do this, using this syntax:

Style myStyle = new Style();

myStyle.ForeColor = System.Drawing.Color.Purple;

myStyle.BackColor = System.Drawing.Color.LightGreen;

Page.Header.StyleSheet.CreateStyleRule(myStyle, this, ".testClass");



But not every available property will have a value defined for it in my
database. Is there a way to set the property and value by name and value,
like

myStyle.SetProperty("Color","Red")

Or a better way to achieve this...?

Thanks in advance,

Jason
 
G

Guest

Hi

did you look for something like

myStyle.Add("background-color", "silver");

this way you'd set new value to the "background-color"

is this what you where looking for ?

Adlai


--
-------------------------------------
If my answer helped you please press "Yes" bellow

×× ×ª×©×•×‘×” זו עזרה לך, ×× × ×”×¦×‘×¢ "כן"

Adlai Maschiach
http://blogs.microsoft.co.il/blogs/adlaim/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top