locked
Change Background colour depending on query RRS feed

  • Question

  • User-1754072641 posted

    Hi, i have asn ASP page that contains 1 table.

    In the table i have placed a HDD icon.

    I want to achieve the following.

    Depending on an SQL query to our monitoring server:

    If the query returns a value it means that servers have a hdd problem, then i  want to change the background to red.

    If the query is empty, it means there are no problems in any of the servers so the background should be green.

    Is there a way to achieve this?

    Thanks

    Thursday, August 23, 2012 7:07 AM

Answers

  • User1264447444 posted

    Add a runat="server" property and id="imageholdercell" property to your 

    <td class="style3" style="background-color: #00FF00" runat="server" id="imageholdercell">
    Then in the code behind get the value from the database and based on the value change the color of the td
    imageholdercell.Style["Background-Color"] = Color.Red;
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 24, 2012 11:27 AM

All replies

  • User1264447444 posted

    Are you trying the change the background of the table or the icon?

    Can you post your html code?

    Thursday, August 23, 2012 10:25 AM
  • User-1754072641 posted

    Hi,  i am trying to change the background.

    Actually i am thinking that the background should be always green, but if a query returns a value(meaning there is an error) then it should change to red.

    I don't have much code now. As i don't know what to use in order to achieve what i need.

    <td class="style3" style="background-color: #00FF00">
    <asp:Image ID="Image2" runat="server" Height="63px" ImageAlign="Middle" 
    ImageUrl="~/images/Windows_HDD.png" Width="75px" />
    </td>
    <td>

    Thanks

    Thursday, August 23, 2012 4:55 PM
  • User1264447444 posted

    Add a runat="server" property and id="imageholdercell" property to your 

    <td class="style3" style="background-color: #00FF00" runat="server" id="imageholdercell">
    Then in the code behind get the value from the database and based on the value change the color of the td
    imageholdercell.Style["Background-Color"] = Color.Red;
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 24, 2012 11:27 AM