bvandrunen
bvandrunen

Reputation: 443

Making my color set to a variable

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

Answers (3)

Brendan
Brendan

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

CodingGorilla
CodingGorilla

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

Singleton
Singleton

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

Related Questions