I would like to be able to pull some code samples out of a database and/or have the text embedded into the website and then have the sample formatted in a code like fashion on the screen. While the text alone on the screen is great, the format will make it more user friendly. How is this done?
I want this:
public string MyString = ‘The Sample Text’;
To look like:
public string MyString = 'The Sample Text';
EDIT WITH ANSWER
I took Gortok’s suggestion and looked into Prettify.js and its doing just what I had hoped. Here is how this is implemented.
<head runat='server'> <script src='Scripts/prettify.js' type='text/javascript'></script> <script src='Scripts/jquery-1.3.2.js' type='text/javascript'></script> <link href='Scripts/prettify.css' rel='stylesheet' type='text/css'></link> </head> <body> <code class='prettyprint'> public String HelloString = 'New String'; </code> <script language='javascript'> $().ready(function() { prettyPrint(); }); </script> </body>
Stack Overflow uses prettify.js from Google.