Articles → .NET → Codeplex Syntax Highlighter

Codeplex Syntax Highlighter






Software Requirement





Prerequisite Knowledge




  1. Know how to create a web application (or website).
  2. How to add a reference in the project?
  3. What are namespace and class in .net?
  4. What is a DLL? How to use it?

What Is Syntax Highlighter?








using Test;





Scenario Of Using Syntax Highlighter





Download DLL









Creation Of A Website


Picture showing the sample web application project created in visual studio
Click to Enlarge




Adding DLL Reference




Picture showing adding the reference of ColorCode.dll in the project
Click to Enlarge



Picture showing the ColorCode.dll added in the project
Click to Enlarge


Creating Text File




Picture showing the sample code file to be used for syntax highlighter
Click to Enlarge


Adding Code In A Web Page




using System;
using System.IO;
using ColorCode;

public partial class _Default: System.Web.UI.Page {
  protected void Page_Load(object sender, EventArgs e) {
    string code = File.ReadAllText(Server.MapPath(@"~\code.txt"));
    string colorCode = new CodeColorizer().Colorize(code, Languages.Aspx);

    Response.Write(colorCode);
  }
}



Code Explained







Run Application




Picture showing the code after highlighting using colorcode.dll
Click to Enlarge


Conclusion





Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, February 14, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250