开发者

Making my color set to a variable

开发者 https://www.devze.com 2023-01-25 19:16 出处:网络
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:\"<%= Acc开发者_开发知识库ountWarningStyle %>\"; font-size:14

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:"<%= Acc开发者_开发知识库ountWarningStyle %>"; font-size:14px;"></span>

AccountWarningStyle is my c# variable


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;">


You have quotation marks around your C# code: "<% ... %>". The first quote makes your browser think your style attribute is finished immediately after "color:"


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

0

精彩评论

暂无评论...
验证码 换一张
取 消