如何显示特定颜色的文字控制 [英] how to display literal control in specific color

查看:145
本文介绍了如何显示特定颜色的文字控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//我有我想要的情况下,问题不回答我重视以下code到文字设置控制测量形式页面。我想知道如果我可以改变文本的颜色字面里面为红色。

 如果(RadioButtonList1.SelectedItem == NULL)
   {
       字符串showmsg =请回答问题;
       Literal1.Text = showmsg;
   }


解决方案

为它供给HTML

 字符串showmsg =<跨度风格=颜色:红色'>请回答问题< / SPAN>中;

这将呈现为多个跨度。它如果您使用支持从C#code颜色变化等控制较好。像标签,并使用其财产的 Label.ForeColor

// I have a survey style page that I want to setup controls in case a question is not answered I have attached the following code to a Literal. I would like to know if I can change the color of the text inside the literal to Red.

if (RadioButtonList1.SelectedItem == null)
   {
       string showmsg = "Please Answer Question";
       Literal1.Text = showmsg;
   }

解决方案

Supply it HTML

string showmsg = "<span style='color:red'> Please Answer Question </span>";

That will be rendered as multiple spans. Its better if you use other controls which supports colour change from the C# code. Like Label and use its property Label.ForeColor

这篇关于如何显示特定颜色的文字控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆