Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

can I define custom colors?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jrl - 07 Mar 2008 03:22 GMT
Is there any way to define a custom color, in the code files of a web site
project?

I'd like to be able to define a pallette, using my own names, and then be
able to use those names in aspx files.
I know I can define styles, and use CSS on controls. But it seems like I
should be able to define a color name, and have it interpreted into the rgb
during rendering.

For example, it would be something like:

color sage=(A0, B0, C0); // defining the color name

<body bgcolor=sage> //in the aspx
Steven Cheng - 07 Mar 2008 05:47 GMT
Hi Jrl,

As for defining some custom colors for using in aspx page, I think it is
still better to use css for client-side html elements since there is no
particular html standard approachs that can help define custom colors only.

For controls that can utilize asp.net server-side expression, you can
consider put your custom colors into a global resource file(resx) and use
resource expression to embed color into control property. e.g.

==============
<asp:Button ID="btnSet" runat="server" ...  BackColor='<%$
Resources:colors, color1 %>' />
==============

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response

from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take

approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution.

The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump

analysis issues. Issues of this nature are best handled working with a
dedicated Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
[quoted text clipped - 15 lines]
>
><body bgcolor=sage> //in the aspx
jrl - 09 Mar 2008 07:03 GMT
Thanks Steven,

I learned how to set up a global resource, and set color names and values
there. Then I was able to use these in a control as you described (except
that it used double quotes as opposed to single quotes: BackColor="<%$
Resources:colors, color1 %>"  )

And actually, I would like to use these named colors in the definition of
CSS elements, but how can I specify an expression bound value in the CSS
file? Since I'm wanting to define site-wide colors, to be used in the style
sheet.

I tried using a style sheet definition like         background-color: "<%$
Resources:Resource, color1 %>";
which would be similar to how it is used on a control, but this isn't
accepted.

Is there a special format to bind a stylesheet color to a resource?

thanks,

> Hi Jrl,
>
[quoted text clipped - 80 lines]
>>
>><body bgcolor=sage> //in the aspx
Steven Cheng - 10 Mar 2008 05:28 GMT
Hi Jrl,

Thanks for your reply.

Do you mean use the <% ... %> expression in static css style file? I'm
afraid this is not supported since <%XX  %> expression is working in ASPX
page only.

If you want to let the css stylesheet contains some values that are
dynamically loaded(from resource or other location). I think you may
consider using a custom httphandler to output the css stylesheet and do
some string replacement in the httphandler for the css stylesheet.

For example, you can define the following kind of static css template:

=======
.myclass
{
background-color: [#colorID];
...
}
=======

your httphandler need to parse the requested css style template and replace
those #colorID with actual values(loaded from resource file or other place).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

--------------------
>From: "jrl" <jrl@newsgroup.nospam>
>Newsgroups: microsoft.public.vsnet.general
>Subject: Re: can I define custom colors?

>Thanks Steven,
>
[quoted text clipped - 51 lines]
>> ==================================================
>> Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications.
>>
[quoted text clipped - 44 lines]
>>>
>>><body bgcolor=sage> //in the aspx
jrl - 10 Mar 2008 07:28 GMT
Yes, this is exactly what I'm seeking. As this is a new area for me, I will
probably need to find some example I can learn from (to make a custom
httphandler).
If you happen to know an example you can link to, that would be appreciated.
However, I realize this is a lot to ask, and if it is not easily available,
I will search for it in other ways.

thanks,

> Hi Jrl,
>
[quoted text clipped - 158 lines]
>>>>
>>>><body bgcolor=sage> //in the aspx
Steven Cheng - 10 Mar 2008 09:06 GMT
Yes, I know some examples since this is also a common question:).

One good example is building a Image generator through httphandler. It
demonstrate how to use httphandler to create a handler that will return
dynamic image stream to client(so that you can display the stream through
<img> tag).

Here are the related articles about creating custom httphandlers:

#Extending ASP.NET with HttpHandlers and HttpModules (cont'd)
http://www.devx.com/dotnet/Article/6962/0/page/3

#Build an ASP.NET Thumbnail Image Generator
http://www.eggheadcafe.com/articles/20041104.asp

#Use Custom HTTP Handlers in Your ASP.NET Applications
http://www.developer.com/net/asp/article.php/3565541

Best regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
>Newsgroups: microsoft.public.vsnet.general
>Subject: Re: can I define custom colors?

>Yes, this is exactly what I'm seeking. As this is a new area for me, I will
>probably need to find some example I can learn from (to make a custom
[quoted text clipped - 112 lines]
>>>> ==================================================
>>>> Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>> ications.
>>>>
[quoted text clipped - 49 lines]
>>>>>
>>>>><body bgcolor=sage> //in the aspx

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.