C#: Change the color of a button
Solved
Charlingals1
Posted messages
30
Status
Member
-
Charlingals1 Posted messages 30 Status Member -
Charlingals1 Posted messages 30 Status Member -
Bonjour,
I am programming a web application, and I would like to change the color of a button in my C# code,
The button code is as follows
This button is associated with a stylesheet
I just want the button color to change from orange to gray
If you could help me, that would be great
Best regards
Thank you
I am programming a web application, and I would like to change the color of a button in my C# code,
The button code is as follows
<asp:Button Cssclass="exearchivage" ID="Archivage" runat="server" Text="Archive the current year's data" OnClick="Archivage_Click"/>
This button is associated with a stylesheet
.exearchivage { position: absolute; /*top, right, bottom, and left.*/ padding: 5px 20px 5px 20px; left: 70px; top: 520px; height: 30px; width: 1000px; border: black thin solid; background-color: orange; color: black; text-align: center; text-decoration: none; } I just want the button color to change from orange to gray
If you could help me, that would be great
Best regards
Thank you
Configuration: Windows XP Internet Explorer 6.0
1 answer
-
Hello
So you need to change a variable in the css file
position: absolute;
/*top, right, bottom and left.*/
padding: 5px 20px 5px 20px;
left: 70px;
top: 520px;
height: 30px;
width: 1000px;
border: black thin solid;
background-color: grey;
color: black;
text-align: center;
text-decoration: none
Here, replace your file with this, and let me know if it works
cya++-
Hello,
What I want is for my button to be orange when the date is between 15/08 and 31/09, so the test is good, it works perfectly, but I can't change the color of the button.
If you have any ideas, I'm interested.
Best regards.- re,
In your first post, you wanted a gray button instead of the orange one, now you want the orange button instead of the gray one???
I don't really understand. Otherwise, if you want your buttons to change color depending on the date, that is to say,
orange when the date is between 15/08 and 31/09 and gray when the date is not included, you would need to include a variable in your php page.
Here's an example:
<?php
session_start();
if(date is between 15/08 and 31/09) then call the style sheet button.css in this file the button is orange
If not then call the style sheet button1.css (the file where the button is gray)
I can't help you with programming because I don't master it too well.
Otherwise, someone else could do it.
There you go, hoping to help you. - Thank you
It works perfectly, I duplicated my CSS class and modified the class in the code
for those interested, here is the code
today = DateTime.Today; start = new DateTime(Convert.ToInt16(odataset.Tables["Year"].Rows[0][1].ToString()), 8, 15); end = new DateTime(Convert.ToInt16(odataset.Tables["Year"].Rows[0][1].ToString()), 10, 1); if (((today.CompareTo(end)) > 0) || ((today.CompareTo(start)) < 0)) { Archive.CssClass = "exearchivageinactive"; } else { Archive.CssClass = "exearchivage"; }
exearchivageinactive and exearchivage are CSS classes where the first has a backcolor value equal to grey and the second backcolor is equal to orange
Best regards
-