InternetEngineer.com Logo

ASP.NET CODE SNIPPETS WITH SYNTAXHIGHLIGHTER


If you want to display fancy code snippets in your asp.net web site..... SyntaxHighlighter is one of the best tools available.
This script uses JQUERY and SyntaxHighlighter script.
Module HelloWorld
	Sub Main( )
		System.Console.WriteLine("Hello world!")
	End Sub
End Module					

SyntaxHighlighter was developed by Alex Gorbatchev

You can download the original SyntaxHighlighter from:
http://alexgorbatchev.com/SyntaxHighlighter/

If you want to download a working model that already uses ASP.NET from my site please use the following link:
syntaxhighlighter-for-asp-net.zip

There are different script types for different types of codes (ASP.NET, SQL, PHP, Etc). Activating all scripts in the same page will affect performance.

So each page will carry all the scripts available. You need comment out the ones not used.
<head>
<script type="text/javascript" src="scripts/shCore.js"></script> 
<!--<script type="text/javascript" src="scripts/shBrushBash.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushCpp.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushCSharp.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushCss.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushDelphi.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushDiff.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushGroovy.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushJava.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushJScript.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushPhp.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushPlain.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushPython.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushRuby.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushScala.js"></script>--> 
<!--<script type="text/javascript" src="scripts/shBrushSql.js"></script>--> 
<script type="text/javascript" src="../scripts/shBrushVb.js"></script> 
<!--<script type="text/javascript" src="scripts/shBrushXml.js"></script>--> 
<link type="text/css" rel="stylesheet" href="../styles/shCore.css"/> 
<link type="text/css" rel="stylesheet" href="../styles/shThemeDefault.css"/> 
<script type="text/javascript"> SyntaxHighlighter.config.clipboardSwf = '../scripts/clipboard.swf'; SyntaxHighlighter.all(); </script> 
</head>			
Then you must display the code inside the div as shown below. A good practice is to left justify the code completely inside the HTML.
Before you copy and paste the code, place the code in notepad and then paste into your web editor and not the html editor.
That way the web editor will think its pure text.

<pre class="brush: vbnet;">Module HelloWorld
    Sub Main( )
        System.Console.WriteLine(&quot;Hello world!&quot;)
        End Sub
    End Module
</pre>

One last thing you need to mention jQUERY in your head
<head>
<script type="text/javascript" src="../js/jquery-1.4.2.js"></script>
</head>
			
Don't forget that every code section has a CSS style sheet that assigns colors. If you download the syntaxhighlighter-for-asp-net.zip you will have the scripts necessary.

Send me an email if you need help.




 

 

 

 

 

Socialize de Tech
Tour de Web
Internet Culture
If you are an Internet Engineer here are some tips that can help you improve your career and sometimes your life.....Introduction A different way of thinking Fitness & Mental Health Personal Goals Your future
Inspiration for this site

Check out some of the sites I admire
© Web Design by Christian Rodriguez | Copyright 2010 InternetEngineer.com
Contact: 305.788.2942 | skype: skype.christian.rodriguez