Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3947736
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:17:15+00:00 2026-05-20T01:17:15+00:00

<table style=width: 100%; background-color: #B5C7DE> i have this table and want to change the

  • 0
<table style="width: 100%; background-color: #B5C7DE">

i have this table and want to change the background-color to be yellow if the server used int he SQL connection string is not ‘pheddv20’

i am adding c# code to the page load event to check for this and run the dynamic logic. the connection string is held in the web.config as is typically seen…

whats the code look like for this type of action?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:17:15+00:00Added an answer on May 20, 2026 at 1:17 am

    It’s better to mark the table with a css class:

    <style type="text/css">
     .releasedata{background:red}
     .testdata{background:yellow}
    </style>
    <table class='<%= GetTableClassForEnvironment() %>'>...</table>
    

    In your code behind you’d want to add the method

    protected string GetTableClassForEnvironment()
    {
    /*
      parse environment string from web.config using ConfigurationManager.ConnectionStrings 
    http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx
    */
    }
    

    This wasn’t in your post, but I’m guessing you want to have the table show up in different colors depending on the environment (ie. debug/release/qa). You should look into using web.config transormations. If you do that you can use conditional compilation statements in your code behind and you won’t have to rely on web.config parsing. So your method becomes

    protected string GetTableClassForEnvironment()
    {
    #IF DEBUG
     return "releasedata"
    #ELSE
     return "testdata"
    #END IF
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code is pretty simple: <table id=tabel_user style=width: 100%; border: 0; background-color: white; cellpadding=0
i have this html code <table style=width: 100%;> <tr> <td> ID </td> <td> <input
I have the following HTML table: <table style=width: 100%;> <tr> <td class=title_bar_left_border></td> <td class=title_bar_middle></td>
I have a table as below; <table style=width: 100%; border: solid 1px #666600; min-width:
To understand what I mean, please see this snippet: <table style=width: 100%> <tbody><tr><td> <div
I have the following: <ul style=width: 300px; list-style-type:none> <li> <table style=width:100% border=0 cellpadding=0 cellspacing=0
I have a table with a header and an empty body: <table style=width:50%; class=adminlist>
I have table View with grouped style with three sections. Get information from dictionary
I have a table view with some words, and i present flash-card style landscape
I have a fairly simple cell in a table with an inline style: <td

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.