473,491 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Modify CSS class.

I have given up looking for a solution so I figured I would break down
and ask.

I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple

HTMLID.Style["width"] = "10px";

however I need to apply it to a CSS class not a single ID.
What is the code for that?

Thanks

Feb 15 '07 #1
9 2008
you could try to output it as an internal style, that way you only really
need to repalce the string containing the width attribute as part of your
page output

http://ryanfarley.com/blog/archive/2.../24/18930.aspx

--
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

"Will" <wd******@rmi.netwrote in message
news:11*********************@k78g2000cwa.googlegro ups.com...
>I have given up looking for a solution so I figured I would break down
and ask.

I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple

HTMLID.Style["width"] = "10px";

however I need to apply it to a CSS class not a single ID.
What is the code for that?

Thanks

Feb 15 '07 #2
If it's a WebControl, change the CssClass property.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Will" <wd******@rmi.netwrote in message
news:11*********************@k78g2000cwa.googlegro ups.com...
>I have given up looking for a solution so I figured I would break down
and ask.

I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple

HTMLID.Style["width"] = "10px";

however I need to apply it to a CSS class not a single ID.
What is the code for that?

Thanks

Feb 15 '07 #3
Most of the time it will not be a webcontrol.

So far the two solutions I have come up with are, hardcode the ID of
each object I need to apply this to or write some asp.net that
modifies some javascript since javascript can easily make a change to
a css class.

On Feb 15, 1:49 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
If it's a WebControl, change the CssClass property.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Will" <wdiet...@rmi.netwrote in message

news:11*********************@k78g2000cwa.googlegro ups.com...
I have given up looking for a solution so I figured I would break down
and ask.
I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple
HTMLID.Style["width"] = "10px";
however I need to apply it to a CSS class not a single ID.
What is the code for that?
Thanks- Hide quoted text -

- Show quoted text -

Feb 15 '07 #4
What is this then ? You can always change the class name.

IMO it will more manageable to change the classname depending on whatever
the condition is rather than to alter the class definition (is this what you
had in mind ?). You could do this frlom ASPX (after all an ASPX page could
perfectly serve CSS content) or using javascript.

Knowing what exactly you are trying to do could perhaps allows someone to
sugest another approach for the problem you try to solve (for example my
first thought would be rather to have a "MyName" and "MyName_Alternate"
class and to use the appropriate name depending on whatever the condition
is.

"Will" <wd******@rmi.neta écrit dans le message de news:
11**********************@v45g2000cwv.googlegroups. com...
Most of the time it will not be a webcontrol.

So far the two solutions I have come up with are, hardcode the ID of
each object I need to apply this to or write some asp.net that
modifies some javascript since javascript can easily make a change to
a css class.

On Feb 15, 1:49 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
>If it's a WebControl, change the CssClass property.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Will" <wdiet...@rmi.netwrote in message

news:11*********************@k78g2000cwa.googlegr oups.com...
>I have given up looking for a solution so I figured I would break down
and ask.
I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple
HTMLID.Style["width"] = "10px";
however I need to apply it to a CSS class not a single ID.
What is the code for that?
Thanks- Hide quoted text -

- Show quoted text -


Feb 15 '07 #5
Oh BTW I've done something similar for "theming" and ASP application while
keeping the existing layout unchanged (basically it uses a general sheet
that perform the general layout and use one of the multiple sheets that
handle colors).

Bascially you could just inject the appropriate CSS change inside this
particular page. It should "override" just the property you want for this
class.
So your page would use the usual style sheet but would embed a style tag for
this particular css class name so that you can override part of all of its
properties.

The best approach likely depends about what is the purpose of this kind of
"override"...

"Patrice" <http://www.chez.com/scribe/a écrit dans le message de news:
%2****************@TK2MSFTNGP02.phx.gbl...
What is this then ? You can always change the class name.

IMO it will more manageable to change the classname depending on whatever
the condition is rather than to alter the class definition (is this what
you had in mind ?). You could do this frlom ASPX (after all an ASPX page
could perfectly serve CSS content) or using javascript.

Knowing what exactly you are trying to do could perhaps allows someone to
sugest another approach for the problem you try to solve (for example my
first thought would be rather to have a "MyName" and "MyName_Alternate"
class and to use the appropriate name depending on whatever the condition
is.

"Will" <wd******@rmi.neta écrit dans le message de news:
11**********************@v45g2000cwv.googlegroups. com...
>Most of the time it will not be a webcontrol.

So far the two solutions I have come up with are, hardcode the ID of
each object I need to apply this to or write some asp.net that
modifies some javascript since javascript can easily make a change to
a css class.

On Feb 15, 1:49 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
>>If it's a WebControl, change the CssClass property.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Will" <wdiet...@rmi.netwrote in message

news:11*********************@k78g2000cwa.googleg roups.com...

I have given up looking for a solution so I figured I would break down
and ask.

I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple

HTMLID.Style["width"] = "10px";

however I need to apply it to a CSS class not a single ID.
What is the code for that?

Thanks- Hide quoted text -

- Show quoted text -



Feb 15 '07 #6
That was the original route I went, making a different class, and alt,
and then swaping thoses around, that was after looking at at themes.
However that because a mess because it is more then 1 CSS class.

I then tried to add mutliple CSS classes but that just ran into
problems on that. So the next idea was just modify the CSS class as
needed, since it is so easy to do with IDs. As it is I now I am more
interested in it from a curiosity standpoint.

On Feb 15, 3:24 pm, "Patrice" <http://www.chez.com/scribe/wrote:
What is this then ? You can always change the class name.

IMO it will more manageable to change the classname depending on whatever
the condition is rather than to alter the class definition (is this what you
had in mind ?). You could do this frlom ASPX (after all an ASPX page could
perfectly serve CSS content) or using javascript.

Knowing what exactly you are trying to do could perhaps allows someone to
sugest another approach for the problem you try to solve (for example my
first thought would be rather to have a "MyName" and "MyName_Alternate"
class and to use the appropriate name depending on whatever the condition
is.

"Will" <wdiet...@rmi.neta écrit dans le message de news:
1171545162.582554.217...@v45g2000cwv.googlegroups. com...
Most of the time it will not be a webcontrol.
So far the two solutions I have come up with are, hardcode the ID of
each object I need to apply this to or write some asp.net that
modifies some javascript since javascript can easily make a change to
a css class.
On Feb 15, 1:49 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
If it's a WebControl, change the CssClass property.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com
The shortest distance between 2 points is a curve.
"Will" <wdiet...@rmi.netwrote in message
>news:11*********************@k78g2000cwa.googlegr oups.com...
I have given up looking for a solution so I figured I would break down
and ask.
I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple
HTMLID.Style["width"] = "10px";
however I need to apply it to a CSS class not a single ID.
What is the code for that?
Thanks- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Feb 15 '07 #7
Or see my other post (basically you perhaps "inject" those CSS changes
inside your ASPX page to "overrides" previously defined values).

Why do you have so much changes ? Do you alter the appearance based on the
current state of something ?
"Will" <wd******@rmi.neta écrit dans le message de news:
11*********************@m58g2000cwm.googlegroups.c om...
That was the original route I went, making a different class, and alt,
and then swaping thoses around, that was after looking at at themes.
However that because a mess because it is more then 1 CSS class.

I then tried to add mutliple CSS classes but that just ran into
problems on that. So the next idea was just modify the CSS class as
needed, since it is so easy to do with IDs. As it is I now I am more
interested in it from a curiosity standpoint.

On Feb 15, 3:24 pm, "Patrice" <http://www.chez.com/scribe/wrote:
What is this then ? You can always change the class name.

IMO it will more manageable to change the classname depending on whatever
the condition is rather than to alter the class definition (is this what
you
had in mind ?). You could do this frlom ASPX (after all an ASPX page could
perfectly serve CSS content) or using javascript.

Knowing what exactly you are trying to do could perhaps allows someone to
sugest another approach for the problem you try to solve (for example my
first thought would be rather to have a "MyName" and "MyName_Alternate"
class and to use the appropriate name depending on whatever the condition
is.

"Will" <wdiet...@rmi.neta écrit dans le message de news:
1171545162.582554.217...@v45g2000cwv.googlegroups. com...
Most of the time it will not be a webcontrol.
So far the two solutions I have come up with are, hardcode the ID of
each object I need to apply this to or write some asp.net that
modifies some javascript since javascript can easily make a change to
a css class.
On Feb 15, 1:49 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
If it's a WebControl, change the CssClass property.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com
The shortest distance between 2 points is a curve.
"Will" <wdiet...@rmi.netwrote in message
>news:11*********************@k78g2000cwa.googlegr oups.com...
I have given up looking for a solution so I figured I would break down
and ask.
I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple
HTMLID.Style["width"] = "10px";
however I need to apply it to a CSS class not a single ID.
What is the code for that?
Thanks- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -


Feb 15 '07 #8
Laziness on my part and user requirement.

They want some parts of the design to change to change depending on
role of the user, type of data being shown and if it is real or
teaching server. Most of them are very simple visiblity, color or
font-style type changes.

I don't want to have to handle alot of multiple file and versions so I
handleing most stuff with as few different stylesheet I can and
settings in the config file. Then in thoses cases that changes had
to be done based on data I didn't want to have to change to every
object I figured I could do a quick change to the few classes since
they already had everything but one or two properties that needed to
be changed.

I will probably just go with changing each ID; just a bunch of extra
lines and a chance that I will miss something but easier to change.

On Feb 15, 5:17 pm, "Patrice" <http://www.chez.com/scribe/wrote:
Or see my other post (basically you perhaps "inject" those CSS changes
inside your ASPX page to "overrides" previously defined values).

Why do you have so much changes ? Do you alter the appearance based on the
current state of something ?

"Will" <wdiet...@rmi.neta écrit dans le message de news:
1171551997.528347.29...@m58g2000cwm.googlegroups.c om...
That was the original route I went, making a different class, and alt,
and then swaping thoses around, that was after looking at at themes.
However that because a mess because it is more then 1 CSS class.

I then tried to add mutliple CSS classes but that just ran into
problems on that. So the next idea was just modify the CSS class as
needed, since it is so easy to do with IDs. As it is I now I am more
interested in it from a curiosity standpoint.

On Feb 15, 3:24 pm, "Patrice" <http://www.chez.com/scribe/wrote:
What is this then ? You can always change the class name.
IMO it will more manageable to change the classname depending on whatever
the condition is rather than to alter the class definition (is this what
you
had in mind ?). You could do this frlom ASPX (after all an ASPX page could
perfectly serve CSS content) or using javascript.
Knowing what exactly you are trying to do could perhaps allows someone to
sugest another approach for the problem you try to solve (for example my
first thought would be rather to have a "MyName" and "MyName_Alternate"
class and to use the appropriate name depending on whatever the condition
is.
"Will" <wdiet...@rmi.neta écrit dans le message de news:
1171545162.582554.217...@v45g2000cwv.googlegroups. com...
Most of the time it will not be a webcontrol.
So far the two solutions I have come up with are, hardcode the ID of
each object I need to apply this to or write some asp.net that
modifies some javascript since javascript can easily make a change to
a css class.
On Feb 15, 1:49 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
>If it's a WebControl, change the CssClass property.
>--
>HTH,
>Kevin Spencer
>Microsoft MVP
>Software Composerhttp://unclechutney.blogspot.com
>The shortest distance between 2 points is a curve.
>"Will" <wdiet...@rmi.netwrote in message
>>news:11*********************@k78g2000cwa.googleg roups.com...
>I have given up looking for a solution so I figured I would break down
and ask.
I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple
HTMLID.Style["width"] = "10px";
however I need to apply it to a CSS class not a single ID.
What is the code for that?
Thanks- Hide quoted text -
>- Show quoted text -- Hide quoted text -
- Show quoted text -

Feb 15 '07 #9
Rather than using inline styles, why don't you just put a Literal Control on
the page that contains a style sheet? That way you can control all the
styles in the page from one control.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Will" <wd******@rmi.netwrote in message
news:11**********************@k78g2000cwa.googlegr oups.com...
Laziness on my part and user requirement.

They want some parts of the design to change to change depending on
role of the user, type of data being shown and if it is real or
teaching server. Most of them are very simple visiblity, color or
font-style type changes.

I don't want to have to handle alot of multiple file and versions so I
handleing most stuff with as few different stylesheet I can and
settings in the config file. Then in thoses cases that changes had
to be done based on data I didn't want to have to change to every
object I figured I could do a quick change to the few classes since
they already had everything but one or two properties that needed to
be changed.

I will probably just go with changing each ID; just a bunch of extra
lines and a chance that I will miss something but easier to change.

On Feb 15, 5:17 pm, "Patrice" <http://www.chez.com/scribe/wrote:
Or see my other post (basically you perhaps "inject" those CSS changes
inside your ASPX page to "overrides" previously defined values).

Why do you have so much changes ? Do you alter the appearance based on the
current state of something ?

"Will" <wdiet...@rmi.neta écrit dans le message de news:
1171551997.528347.29...@m58g2000cwm.googlegroups.c om...
That was the original route I went, making a different class, and alt,
and then swaping thoses around, that was after looking at at themes.
However that because a mess because it is more then 1 CSS class.

I then tried to add mutliple CSS classes but that just ran into
problems on that. So the next idea was just modify the CSS class as
needed, since it is so easy to do with IDs. As it is I now I am more
interested in it from a curiosity standpoint.

On Feb 15, 3:24 pm, "Patrice" <http://www.chez.com/scribe/wrote:
What is this then ? You can always change the class name.
IMO it will more manageable to change the classname depending on
whatever
the condition is rather than to alter the class definition (is this what
you
had in mind ?). You could do this frlom ASPX (after all an ASPX page
could
perfectly serve CSS content) or using javascript.
Knowing what exactly you are trying to do could perhaps allows someone
to
sugest another approach for the problem you try to solve (for example my
first thought would be rather to have a "MyName" and "MyName_Alternate"
class and to use the appropriate name depending on whatever the
condition
is.
"Will" <wdiet...@rmi.neta écrit dans le message de news:
1171545162.582554.217...@v45g2000cwv.googlegroups. com...
Most of the time it will not be a webcontrol.
So far the two solutions I have come up with are, hardcode the ID of
each object I need to apply this to or write some asp.net that
modifies some javascript since javascript can easily make a change to
a css class.
On Feb 15, 1:49 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
>If it's a WebControl, change the CssClass property.
>--
>HTH,
>Kevin Spencer
>Microsoft MVP
>Software Composerhttp://unclechutney.blogspot.com
>The shortest distance between 2 points is a curve.
>"Will" <wdiet...@rmi.netwrote in message
>>news:11*********************@k78g2000cwa.googleg roups.com...
>I have given up looking for a solution so I figured I would break
>down
and ask.
I am trying to modify a CSS class in page_load. I have no problem
doing it with an ID with the simple
HTMLID.Style["width"] = "10px";
however I need to apply it to a CSS class not a single ID.
What is the code for that?
Thanks- Hide quoted text -
>- Show quoted text -- Hide quoted text -
- Show quoted text -


Feb 16 '07 #10

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

Similar topics

4
3222
by: Sherman Willden | last post by:
I am trying to use Perl's XML::Twig to modify a version number in an XML document. At the very end of this posting is an excerpt from the xml document. Just before the xml excerpt is the Perl code...
5
4459
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a...
3
2316
by: DC Gringo | last post by:
Hi, I'm trying to use a custom action to modify a database (rather than create one) using the VS.NET '03's help example called "Custom Action to Create Database During Installation". I've made...
23
1933
by: no1zson | last post by:
I have been adding buttons to my GUI to manipulate list data. I added a Delete button this morning in case I decide I no longer needed a particular element. I am now working on a modify button, in...
7
2548
by: Boki | last post by:
Hi All, I want to change WindowState of form1 from form2. I tried these two methods, but no luck on both. (1) Declare a public method: /* function of form1 */ public void...
5
1433
by: kidders | last post by:
Below is a script i need to modify to work and its driving me nuts. Essentially it fades the content of an array. The original script specified the object name, I tried to modify it to allow an...
8
1721
by: s0suk3 | last post by:
Hi everyone, I've heard that a 'str' object is immutable. But is there *any* way to modify a string's internal value? Thanks, Sebastian
6
2918
by: chandramohanp | last post by:
Hi I am trying to modify class instance members using reflection. I am having problem when trying to add/remove/display elements related to List<int> member. Following is the code. class...
6
4957
by: Ramesh | last post by:
Hello, I am using the ofstream class to create a text file with keys and values like: Key1=Value10 Key2=Value15 Key3=Value20 In case I need to set a new value for Key2, say value50 - I am...
0
6978
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...
0
7154
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,...
1
6858
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...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
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,...
1
4881
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...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
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...

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.