Change background of aspx that uses a MasterPage

  • Thread starter Thread starter Joe Kovac
  • Start date Start date
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
 
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
 
Back
Top