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 <stylesection in each page's <headsection
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 2 2142
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/
"Jason_SanDiego2006" wrote:
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 <stylesection in each page's <headsection
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
I am not sure it can be done. In any case you can always put a placeholder
in the page header and fill it up with the correct style definitions in
runtime without using the Style class.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Jason_SanDiego2006" <ja*****@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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 <stylesection in each page's <headsection
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: C A Upsdell |
last post by:
I have a site where I am setting a style dynamically, using the JS
statement:
obj.style.backgroundImage = 'url(img/bak_page.jpg)';
where 'obj' is either document.getElementById(id), or...
|
by: Just Dummy |
last post by:
Hi all,
I am struggling with a problem for a long time.
Problem statement:
I have a table and the table can contain n number of rows. i.e., the
table rows will be generataed out of a xml...
|
by: Diane Yocom |
last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but...
I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where...
|
by: Bas Groeneveld |
last post by:
I am developing an ASP.NET application part of which consists of a data
entry wizard defined by entries in a data table - ie the controls on each
page of the wizard are determined by definitions in...
|
by: Chris Mahoney |
last post by:
Hi
Currently I am setting the background image of my page by using the
following code:
<style type="text/css">
BODY { BACKGROUND-IMAGE: url(myimage.jpg) }
</style>
What I would like to do...
|
by: Axel Dahmen |
last post by:
HI,
I want to dynamically add controls to a web page from within a common base
class. Unfortunately, ASP.NET fails with "System.Web.HttpException: The
Controls collection cannot be modified...
|
by: Mark Rae |
last post by:
Hi,
It's easy enough for a child page to manipulate its MasterPage's header
simply by modifying the MasterPage thus:
<header runat="server">
....
....
</header>
|
by: Ed Jay |
last post by:
I generate a DHTML page (a medical report) with dynamically generated text
based on user input (answers to questions). The page length changes
dynamically. I desire that when the page is printed...
|
by: _Who |
last post by:
I use the code below to change to a style sheet that has:
body
{
....
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |