Reputation: 443
I am trying to set my color in a span style to a variable...anyone know why this is wrong?
<span style="font-weight:bold; color:"<%= AccountWarningStyle %>"; font-size:14px;"></span>
AccountWarningStyle is my c# variable
Upvotes: 1
Views: 848
Reputation: 1883
You have quotation marks around your C# code: "<% ... %>". The first quote makes your browser think your style attribute is finished immediately after "color:"
Upvotes: 2
Reputation: 19842
You need to remove the extra quote marks from around the `<%= AccountWarningStyle%>". This will render as:
<span style="font-weight:bold; color:"red"; font-size:14px;">
Where it should be:
<span style="font-weight:bold; color:red; font-size:14px;">
Upvotes: 3
Reputation: 3679
try declaring span
<span id="MySpan" runat="server" />
and then assign color in code behind
do check http://msdn.microsoft.com/en-us/library/7512d0d0(VS.71).aspx
Upvotes: 0