473,626 Members | 3,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dectecting Background-Color setting

Sam
Hi all

I'm looking for a way to detect the background color of my internal webpage
through a stylesheet. And so far, the only solution I find is to open the
styles.css file and parse the BACKGROUND-COLOR field. The problem I'm
having is that I don't know the exact absolute path of the stylesheet file
(styles.css) to access it using stream reader. I have tried to use the
"Path.GetFullPa th" method of the system.IO to get the absolute path but this
method does not seem to return the correct path. It does with the Window
app.

1. Is there a way to open this file based on relative path of the web
current directory
2. Does anyone have any other way to find BACKGROUND-COLOR setting?

Thank You

Sam
Mar 22 '06 #1
2 1238
Sam
Hi Stan,

It works. Thanks for your big help

Regards,

Sam

"Spam Catcher" <sp**********@r ogers.com> wrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"Sam" <as****@yahoo.c om> wrote in news:uv$htCWTGH A.3192
@TK2MSFTNGP09.p hx.gbl:

1. Is there a way to open this file based on relative path of the web
current directory


Yes, use the Server.MapPath command.

i.e. Server.MapPath( "/MyFolder/Test.css") will return c:\inetpub\wwwr oot
\MyFolder\test. css.
2. Does anyone have any other way to find BACKGROUND-COLOR setting?


Manual parsing is the only way : (
--
Stan Kee (sp**********@r ogers.com)

Boycott StarForce!
http://www.glop.org/starforce

Mar 22 '06 #2
You could do this :

1. Make your body element a GenericHtml Control
by adding ID and runat attributes :

<body id="Body1" runat="server">

2. Access the background-color :

string var = Body1.Attribute s["bgcolor"];
or
dim var as string = Body1.Attribute s("bgcolor")

You could also use Steven Cheng's code-behind code :

<body id="bd" runat="server" >
=============== ====

public class BgColorPage : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Text Box txtColor;
protected System.Web.UI.W ebControls.Butt on btnSubmit;
protected HtmlGenericCont rol bd;
=============== ============

private void btnSubmit_Click (object sender, System.EventArg s e)
{
System.Drawing. Color bgcolor =
System.Drawing. ColorTranslator .FromHtml(txtCo lor.Text);

bd.Style["BACKGROUND-COLOR"] = System.Drawing. ColorTranslator .ToHtml(bgcolor );
}

That code works for setting it.
For retrieving it, if you use that code, you could just use :

string var = bd.Style["BACKGROUND-COLOR"];

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Sam" <as****@yahoo.c om> wrote in message news:uv******** ******@TK2MSFTN GP09.phx.gbl...
2. Does anyone have any other way to find BACKGROUND-COLOR setting?

Thank You
Sam

Mar 22 '06 #3

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

Similar topics

2
10468
by: Markus Mohr | last post by:
Hi, everyone, I have a special problem: For every monitor resolution in 200 pixel steps from 800 to 1600 pixels I have an image to be shown as centered background-image. Those images all have the same name and reside in the following physical path structure:
4
9727
by: Mimo Zus | last post by:
I'm hoping that someone can explain what's going on; better yet provide a workaround. I'm designing a centered CSS site based on a 550 pixel wide vertical background image. Onto this background I built a two column layout with nested navigation and content divs. The background image is centered via "background: ... center;", the divs are centered over it via "margin: 0 auto 0 auto;". The problem I'm having in IE6 is inconsistent...
4
5473
by: Gequina | last post by:
Something goes wrong in my script. I'm all new to it so i don't know much yet. I have a set of buttons. And when you click on either of them, the background image will change. Only it's not working. It works when i click on one, but then when i want to click on another, it's not working. What am i doing wrong? thanks in advance
3
2035
by: ribinha | last post by:
Hi all, I am having problems loading background images on my pages. I have created a css to display the images. It works just fine on my test box, but when I tried on real pages it wont upload any images everythin else displays just fine. I used a table and added a background image to every row. when i call the page it shows that it is preloading images but never displays. I have tried to place the css code on the page itself as well. the...
3
3229
by: Viken Karaguesian | last post by:
Hello all, I need somehelp with background tiling. I have a sneaking suspicion that what I want to do is not possible, but I'll ask anyway. :>) First some background: Here's the site in question: www.sayatnova.com (I'm sure many of you have seen this before as I've often asked for help). I've come a long way since I first created the site many moons ago and I'm trying to convert it to a (1) Table-less, (2) Frame-less and (3) Validated...
6
9646
by: Francois Bonzon | last post by:
Any idea how I can launch a background task from a PHP script? For example, when a user posts on my message board, it may fire many e-mail notifications to other users, and other tasks. I want the posting confirmation page to end displaying quickly, without waiting for those notifications or other tasks to complete. So basically what I want is to launch 'background.php' from 'main.php', with the user seeing only the output of - and...
0
2072
by: Jeb Hunter | last post by:
Well, how can I describe this succinctly? I have a page with DIVs that us background images to produce a border effect. It works perfectly well, but I want to make up (for now) 3 different border/background effects. Rather than duplicate the entire chunk of CSS 3 times, I thought "Gee, I should only have to specify the 3 backgrounds (all the other placement directives would be identical). However I must not be correctly specifying the...
3
27206
by: KNDesign | last post by:
I've set a background image to repeat-y and at 100% height. It appears fine when I open the window, but when I resize to a smaller height so that I must scroll down to see the rest, the background image is suddenly gone from the bottom. #background { position: absolute; top: 0px; bottom: 0px; left: 50%;
6
7224
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to display an image. document.images only seems to reference image tags. The collection needs to include background images, input type = image, image maps, css assigned background, etc. Honestly, I am probably not aware of all the possibilities...
1
2444
by: nicky77 | last post by:
Hi, I've created a nav bar using a background image for rollover effects. Everything works as I had hoped, however, for some reason it seems that an area of whitespace (the same size of the background image) is hyperlinked underneath the nav bar. I can't see any errors in the coding below. Any ideas what may be causing this? the page is at http://www.maguiresonline.co.uk/wosis/files/nickysnav.html the html.... <body...
0
8269
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
8711
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8512
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
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
5576
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
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
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.