|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
Are you adding your body control to the "Protected WithEvents" section of your codebehind?
Code:
Protected WithEvents myBody As System.Web.UI.HtmlControls.HtmlGenericControl |
|
#5
|
|||
|
|||
|
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! |
|
#6
|
|||
|
|||
|
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 ![]() |
|
#7
|
|||
|
|||
|
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! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Background colour |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|