473,654 Members | 3,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Color.DarkMagen ta to #hexcolor

I have a color System.Drawing. Color.DarkMagen ta
I would like to output it to the browser as its hex color(not sure what it
is) #993484

This seems like it should work but it isn't.
------------------------------------------------------------------
System.Drawing. Color c = System.Drawing. Color.DarkMagen ta;
string HtmlColor = System.Drawing. Color.ToHtml(c) ;

Response.Write( HtmlColor); //Outputing "DarkMagent a"
------------------------------------------------------------------

Shouldn't the ToHtml() method give me a hex string representation instead of
the color name?
Anyone got any ideas?

--
Ron Vecchi
Nov 18 '05 #1
2 1046
Use function
Function convertToHexCol or(ByVal c As Color) As String
Return "#" + c.ToArgb().ToSt ring("x").Subst ring(2)
End Function

HTH
-Sushila

"Ron Vecchi" <rv*****@xilehd vecchi.com> wrote in message news:#s******** ******@TK2MSFTN GP12.phx.gbl...
I have a color System.Drawing. Color.DarkMagen ta
I would like to output it to the browser as its hex color(not sure what it
is) #993484

This seems like it should work but it isn't.
------------------------------------------------------------------
System.Drawing. Color c = System.Drawing. Color.DarkMagen ta;
string HtmlColor = System.Drawing. Color.ToHtml(c) ;

Response.Write( HtmlColor); //Outputing "DarkMagent a"
------------------------------------------------------------------

Shouldn't the ToHtml() method give me a hex string representation instead of
the color name?
Anyone got any ideas?

--
Ron Vecchi



Nov 18 '05 #2
I think if you created the Color from a KnownColor, it will always return
you the literal. But it's easy enough to produce the results you want

(sorry, it's VB);

Dim c As System.Drawing. Color = System.Drawing. Color.DarkMagen ta
Dim HtmlColor As String = "#"
HtmlColor &= Right("00" & Hex(c.R), 2)
HtmlColor &= Right("00" & Hex(c.G), 2)
HtmlColor &= Right("00" & Hex(c.B), 2)

"Ron Vecchi" <rv*****@xilehd vecchi.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I have a color System.Drawing. Color.DarkMagen ta
I would like to output it to the browser as its hex color(not sure what it
is) #993484

This seems like it should work but it isn't.
------------------------------------------------------------------
System.Drawing. Color c = System.Drawing. Color.DarkMagen ta;
string HtmlColor = System.Drawing. Color.ToHtml(c) ;

Response.Write( HtmlColor); //Outputing "DarkMagent a"
------------------------------------------------------------------

Shouldn't the ToHtml() method give me a hex string representation instead of the color name?
Anyone got any ideas?

--
Ron Vecchi

Nov 18 '05 #3

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

Similar topics

4
5365
by: dan glenn | last post by:
(PHP4.3.4, GD2) How can I save a PNG using GD2 and insure that it saves as a palette-based (8-bit, 256-color) single-color transparancy?? Saving this way, I could be sure that an image loaded from a transparent gif could be saved as a png and the png would work in IE versions 5.5 and greater (IE has bug that messes up png transparancies which use full alpha channel). thanks for any help at all, -dg
6
4100
by: me | last post by:
good day, i found this message: and i want to know more about it too. ========================================== Hey all, example: $s_Colors="0066FF;0066CC;3366CC;0033FF;003399;003366;99CCFF;3399FF;0099FF;66
6
8502
by: rzed | last post by:
I'm using PIL to generate some images which may be rotated at the user's option. When they are rotated, the original image is cropped in the new image (which is fine), and the corners are black (which is not, in this case). I can't find any documented way to change the default fill color (if that's what it is) for the corners, and PIL also doesn't seem to support a flood fill. I have created a flood fill in Python, which works but which...
3
5067
by: Richard A. DeVenezia | last post by:
I hope this is the end of my present 'discovery' phase. I've learned alot about JavaScript in a short time and my head hurts. The following is what came out of all my questions and all the excellent answers (thanks!). It will be the basis of a slightly more complicated function for rendering a two-level navigation bar ( Don't have time to get into design of a multi-styletype renderer for n-level hierarchies. ) This is a single function...
5
3474
by: Chris Beall | last post by:
I'm displaying an image that is also a link against a black background. In Netscape 7.1, the current background color is displayed as a horizontal bar below the image. This allows :hover effects that change the background color to have a visible effect, as this bar changes color. By default, it appears that the color is inherited from the body color, i.e. with no link style applied, the bar is black, and invisible against the background....
4
19891
by: bart plessers | last post by:
Hello, I am making a website where the user can choose a 'skin'. This works with asp en stylesheets. In the stylesheet, a number of tags are (re)defined. The main idea is to have a limited number of colors (lets say 4) and use only these colors to color up every tag. However, with a long list of (custom) styles, it is a lot of work to scan
0
386
by: Supra | last post by:
: error BC30311: Value of type 'System.Drawing.Color' cannot be converted to 'Integer'. Function doColor(ByVal rtb As RichTextBox, ByVal a As String, Optional ByVal f As Integer = 0, Optional ByVal bg As Integer = 0) Dim b As String, n, fgcolor, bgcolor As Integer Dim colour(15) As Color colour(0) = Color.White colour(1) = Color.Black
19
5765
by: MLH | last post by:
I'm wondering if the BackColor property values for the colors built-in to A97 come from some internationally recognized standard. I have a list of a hundred or so colors with hex values and I'm wondering if they are compatible.
59
6918
by: pamelafluente | last post by:
Hi, If I have: <div style="background:anyColorHere"Hi </div> where anyColorHere is any hex string that represent a valid color. How can I invert that background color "anyColorHere" ? Can you point (or suggest) a script
0
8375
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
8290
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
8707
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7306
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
6161
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
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
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.