我爱Aspx >> C#.Net >> asp.net实现C#代码加亮显示_ASP.NET技巧
以下是代码片段:
StringWriter textBuffer = new StringWriter();
Match match= Regex.Match(HTMLStr,@"\",RegexOptions.IgnoreCase | RegexOptions.Compiled);
if(match==null)
{
Response.Write(HTMLStr);
return;
}
string codeType = match.Groups["codeType"].Value;
string content = match.Groups["codeContent"].Value;
if(codeType==String.Empty || content==String.Empty)
{
Response.Write(HTMLStr);
return;
}
// MessageBox.Show(codeType);
// MessageBox.Show(content);
string[] sr = content.Split(Convert.ToChar("\n"));
if(codeType=="C#")
{
textBuffer.Write("<Csharp>\r\n");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixCSLine(sourceLine)) ;
textBuffer.Write("\r\n");
}
textBuffer.Write("</Csharp>");
}
else if(codeType=="JScript.Net")
{
textBuffer.Write("<JScript.Net>\r\n");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixJSLine(sourceLine)) ;
textBuffer.Write("\r\n");
}
textBuffer.Write("</JScript.Net>");
}
else if(codeType=="VB")
{
textBuffer.Write("<VB>\r\n");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixVBLine(sourceLine)) ;
textBuffer.Write("\r\n");
}
textBuffer.Write("</VB>");
}
Ҷƪл˵?
如何实现站点的RSS输出_ASP.NET实..[04-28]
asp.net 2.0中动态修改页面标题_..[04-28]
同时对多个文件进行大量写操作对..[04-28]
发布一个好用的类SafeConvert, 用..[04-28]
DotNet中用到的加密算法总结_ASP..[04-28]
在Asp.net中为图像加入版权信息_..[04-28]
一个极有可能引发ExecutionEngin..[04-28]
asp.net常用代码_ASP.NET技巧[04-28]
[视频]Visual Studio 2005入门之..[04-28]
[视频]Visual Studio 2005入门之..[04-28]
如何实现站点的RSS输出_ASP.NET实..[04-28]
asp.net 2.0中动态修改页面标题_..[04-28]
同时对多个文件进行大量写操作对..[04-28]
发布一个好用的类SafeConvert, 用..[04-28]
DotNet中用到的加密算法总结_ASP..[04-28]
在Asp.net中为图像加入版权信息_..[04-28]
一个极有可能引发ExecutionEngin..[04-28]
asp.net常用代码_ASP.NET技巧[04-28]
[视频]Visual Studio 2005入门之..[04-28]
[视频]Visual Studio 2005入门之..[04-28]