Reputation: 35
I am trying to set the colors of my controls on my webpage to be variables. For example I would store a value of "#000000" in a database and when the page loads it would put that value in the original html tag. So <asp:Button ID="btnTesta" runat="server" Text="Button" ForeColor='<% MYVALUE%>' />
.
Upvotes: 0
Views: 996
Reputation: 20041
This should change your button background color or ForeColor color
yourButtonName.BackColor = Color.Red;
yourButtonName.ForeColor = Color.Black;
You need to include System.Drawing namespace as Color class belongs to that. Like this
using System.Drawing;
And ofcourse you need to add the reference to System.Drawing
DLL in your project to use this namespace and Color class.
Refrence Button background colour
Upvotes: 0
Reputation: 14624
You can assign value from code behind.
btnTesta.ForeColor = System.Drawing.ColorTranslator.FromHtml("yourvaluefromdatabase");
Upvotes: 1