I am trying to change my site master header depending on whether it is being hosted on dev QA or production. Here is the html:
<div id="wrapper">
<form id="form1" runat="server">
<div class="wrapper">
<div>
<div id="siteHeader" runat="server">FTP Forms</div>
...other stuff
<div>
<div class="wrapper">
<asp:ContentPlaceHolder id="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</form>
</div>
The relevant css in my .css file, I have tried this without #siteHeader as well.
#siteHeader.header {
background-color: forestgreen;
color: white;
font-size: 24pt;
font-weight: bold;
padding: 5px;
border-bottom: 1px solid #000;
}
#siteHeader.headerQa {
background-color: yellow;
color: white;
font-size: 24pt !important; // I tried important to no avail...
font-weight: bold;
padding: 5px;
border-bottom: 1px solid #000;
}
siteHeader.headerPrd {
background-color: red;
color: white;
font-size: 24pt;
font-weight: bold;
padding: 5px;
border-bottom: 1px solid #000;
}
Here are the things I have tried. CodeBehind Site.Master.cs, I have tried this in the Page_load, Pre_Init and master_Page_PreLoad and it works on my localhost and dev but not QA, I didn't try on Prod for obvious reasons. Also, the innerText is changed as it should be but not the CSS.
string hostName = Request.ServerVariables["Server_Name"];
if (hostName.ToUpper().Contains("DEV") || hostName.ToUpper().Contains("LOCALHOST)) // tested on local like this for each if statement.
{
siteHeader.InnerText = "FTP Forms -Development";
siteHeader.Attributes["class"] = "header";
Page.Title = "FTP Dev";
}
else if (hostName.ToUpper().Contains("STAGE") || hostName.ToUpper().Contains("LOCALHOST"))
{
siteHeader.InnerText = "FTP Forms - QA";
siteHeader.Attributes["class"] = "headerQa";
Page.Title = "FTP QA";
}
else
{
siteHeader.InnerText = "FTP Forms - Production";
siteHeader.Attributes["class"] = "headerPrd";
Page.Title = "FTP Prod";
}
I also tried commenting that out and doing it in JavaScript which also changed the inner text but not the CSS. I even tried making it inline style once also to no avail. This did not work on my localhost or the server. On LocalHost the else
should take effect
<script type="text/javascript">
var hostName = location.hostname;
if (hostName.indexOf("dev") > -1) {
document.getElementById("siteHeader").className = "header";
document.getElementById("siteHeader").innerText = "FTP - Forms Development";
} else if (hostName.indexOf("stage") > -1) {
document.getElementById("siteHeader").className = "headerQA";
document.getElementById("siteHeader").innerText = "FTP - Forms QA"
} else {
document.getElementById("siteHeader").style = "background-color: red; color: white; font-size: 24pt; font-weight: bold; padding: 5px; border-bottom: 1px solid #000;";
document.getElementById("siteHeader").innerText = "FTP - Forms Production"
}
</script>