当前位置:编程学习 > C#/ASP.NET >>

求救!

请问在后台用编辑器编辑的字体大小,在前台输出时想改变其字体大小要怎么办?
    
  如:后台编辑了文字“编辑字体大小”为18号
      那么输入数据库的内容就是<font size=18>编辑字体大小</font>


但是我现在想在前台的某个位置不要那么大,自己写一个样式调用不行,在输出时加个<font size=12>...</font>也不行,该怎么办?拜托大家了 --------------------编程问答-------------------- 没有人会吗?拜托了 --------------------编程问答-------------------- 要替换才行。

--------------------编程问答--------------------

/// <summary>
  /// 去除HTML标记
  /// </summary>
  /// <param name="strHtml">包括HTML的源码 </param>
  /// <returns>已经去除后的文字</returns>
  public static string StripHTML(string strHtml)
  {
   string [] aryReg ={
          @"<script[^>]*?>.*?</script>",

          @"<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""'])(\\[""'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>",
          @"([\r\n])[\s]+",
          @"&(quot|#34);",
          @"&(amp|#38);",
          @"&(lt|#60);",
          @"&(gt|#62);", 
          @"&(nbsp|#160);", 
          @"&(iexcl|#161);",
          @"&(cent|#162);",
          @"&(pound|#163);",
          @"&(copy|#169);",
          @"&#(\d+);",
          @"-->",
          @"<!--.*\n"
         
         };

   string [] aryRep = {
           "",
           "",
           "",
           "\"",
           "&",
           "<",
           ">",
           " ",
           "\xa1",//chr(161),
           "\xa2",//chr(162),
           "\xa3",//chr(163),
           "\xa9",//chr(169),
           "",
           "\r\n",
           ""
          };

   string newReg =aryReg[0];
   string strOutput=strHtml;
   for(int i = 0;i<aryReg.Length;i++)
   {
    Regex regex = new Regex(aryReg[i],RegexOptions.IgnoreCase );
    strOutput = regex.Replace(strOutput,aryRep[i]);
   }

   strOutput.Replace("<","");
   strOutput.Replace(">","");
   strOutput.Replace("\r\n","");


   return strOutput;
  }


--------------------编程问答--------------------
引用 2 楼 cpp2017 的回复:
要替换才行。

样式是按最近原则的,只能替换<font size=18>编辑字体大小 </font>中size的大小 --------------------编程问答-------------------- 3楼的收藏了 --------------------编程问答-------------------- 3楼这么猛! --------------------编程问答-------------------- 如果不替换,用样式,样式优先级高,但是会影响到其他的元素。

<style>
    font
   {
    font-size:12px;
   } 
</style>
 <font size=18>编辑字体大小 </font>

补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,