.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 27th, 2003, 09:57 AM
IckleJack IckleJack is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 IckleJack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Background colour

Hi all.

I know this is probably a really simple question and i have searched for it but you wouldnt belive how many posts that have the words 'background' and 'colour' in them have absolutly nothing to do with what i want!!!

anyway, all i want is to be able to set the background colour of the page dynamically in the code behind page (using c#). But it has to work in both IE and Netscape (argh!).

As i said, i'm sure it's simple but cant work it out!

Thanks for your help

J.

Reply With Quote
  #2  
Old October 27th, 2003, 08:45 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 16
I think you have to give your body tag an ID and runat=server attribute. Then in your code-behind, add an attribute and value for color programmatically.

Reply With Quote
  #3  
Old October 28th, 2003, 03:11 AM
IckleJack IckleJack is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 IckleJack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks numbernine but it doesnt seem to work. My code behind page doesnt recognise the ID i gave the body tag.

Any other ideas?

Thanks
J

Reply With Quote
  #4  
Old October 28th, 2003, 09:21 AM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 16
Are you adding your body control to the "Protected WithEvents" section of your codebehind?

Code:
Protected WithEvents myBody As System.Web.UI.HtmlControls.HtmlGenericControl

Reply With Quote
  #5  
Old October 28th, 2003, 10:04 AM
IckleJack IckleJack is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 IckleJack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
doh!

No i wasn't. Have done that now (though changing the code you gave me to c#) and yes the page now recognises 'myBody'. However, the list of options provided doesnt include anything like bgcolor. It does have InnerHtml though which i think should work but i have now thought of another problem! (stupid of me not thinking of this earlier).

I am calling a javascript function from the onload bit of the body tag! this obviously wont work if the body tag is set to run at the server! the javascript is preloading images. any ideas how i can get round this?

Thanks very much for your help. i do appreciate it! as you can see, i'm not that good at this!

Reply With Quote
  #6  
Old October 28th, 2003, 10:08 AM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 16
If you add the background color to the body as an attribute it shouldn't interfere with your javascript stuff.

In VB it's:
Code:
myBody.Attributes.Add("bgcolor", "#CCCCCC")


Don't know the C#. Sorry! It's probably the same with a semicolon at the end

Reply With Quote
  #7  
Old October 28th, 2003, 10:21 AM
IckleJack IckleJack is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 IckleJack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
As soon as i add the runat=server tag it blows a fuse!!! The onload bit looks in the code behind page for the function name and says it can't find it. I dont think it will let me run client side and server side code off the same tag! (if i'm wrong please let me know what i need to do to make it realise its js!)

But the attribute thing should work if i get rid of the js so thanks! that's a good thing to know!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Background colour


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap