Change background of aspx that uses a MasterPage

J

Joe Kovac

Hi!

I have a MasterPage with white background. Within my aspx page I want to
change this color using code behind. How can I achieve this easily?

Thanks

Joe
 
G

Guest

Hi!

I have a MasterPage with white background. Within my aspx page I want to
change this color using code behind. How can I achieve this easily?

Joe, you can add to the Page_Load method a definition for a new style:

Style s = new Style();
s.BackColor = System.Drawing.Color.Green; // <-- here's your color
Page.Header.StyleSheet.CreateStyleRule(s, this, "BODY");

This will add a CSS rule to your page

BODY { background-color:Green; }

and a color will be changed

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top