比如 首页:[供应] 测试一下  (供应 颜色如何改变?) 我是后台改代码。 这是代码: <span> <asp:Literal ID="Literal1" runat="server" ></asp:Literal></span> 

解决方案 »

  1.   

    你说的CSS吧?Literal直接在这个控件两边找个样式添加上就好了。
      

  2.   

    Literal1.Text = "<font color='red'>供应</font>"; 
      

  3.   

    是啊,这个literal控件的属性里,有字体大小颜色等的设置
      

  4.   

    Literal1.Text="<font style='color:#f00'>[供应]</font> 测试一下";
    字符串拼接。
      

  5.   

    Use the Literal control to display static text on the Web Forms page. Unlike the Labelcontrol, Literal does not let you apply styles to its content.Text is not HTML encoded before it is displayed in the Literal control. This makes it possible to embed script within HTML tags in the text. If the values for the control come from user input, be sure to validate the values to help prevent security vulnerabilities.
      

  6.   

    <span> <asp:Literal ID="Literal1" runat="server" ></asp:Literal></span>  
      Literal1.Text = "<font color='red'>供应</font>"; 
    在页面显示
    <span> <font color='red'>供应</font></span> 没问题
      

  7.   

    ???
    设置span试试,如:
    <span id="span1" runat ="server"> <asp:Literal ID="Literal1" runat="server" ></asp:Literal></span>后台:
    span1.Attributes.Add("style", "color:#ff0000");
      

  8.   

    A Literal control is used to display text. You cannot apply a style to a literal control. This control will pass the content directly to the client browser, unless you use the Mode property to encode the content. Literal Web Server control doesn't have any visual appearance on a Web Form but is used to insert literal text into a Web Form. This control makes it possible to add HTML code directly in the code designer window without switching to design view and clicking the HTML button to edit the HTML.
      

  9.   

    <span style="color:red">[供应]</span> 测试一下 
      

  10.   

    应该打个 font-color="red"就可以了
      

  11.   

    首先要明白,Literal控件不支持直接应用样式可以这样实现:定义样式,
    .red{
     color:#FF0000;
    }应用样式:
    <span class="red"><asp:Literal ID="Literal1" runat="server"></asp:Literal></span>
      

  12.   

    style=“在这个地方写”
    也就是我们经常说的CSS。
      

  13.   

    <asp:Literal ID="Literal1" runat="server"></asp:Literal>
    Literal1.Text = "<font color=\"red\">供应</font>";结果:供应