1

I want to show C# Editor in a web page, Intellisence not required.

Andrei
  • 42,814
  • 35
  • 154
  • 218
  • Is this what you are looking for? http://stackoverflow.com/questions/2968057/free-open-source-code-editor-ui-control-for-net – user1071979 Oct 02 '13 at 11:35

1 Answers1

9

You could use Code Mirror, it provides support for C, C++ & C# among other languages.

Simple example:

<script src="/Js/codemirror.js"></script>
<script src="/Js/javascript.js"></script>
<script src="/Js/xml.js"></script>
<script src="/Js/css.js"></script>
<script src="/Js/htmlembedded.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        var element = document.getElementById("<%= txtCodeArea.ClientID %>");
        var editor = CodeMirror.fromTextArea(element , {
            parserfile: "/Js/htmlembedded.js",
            stylesheet: "/Css/codemirror.css",
            path: "/Js/"
        });
    });
</script>

Load in the relevant js files, you find these in the mode folder from the download.

The script gets the element you want to use for code editing and includes the syntax highlighting/coloring for the .js files that you've included. txtCodeArea could refer to a multi-line <asp:TextBox />.

DGibbs
  • 14,316
  • 7
  • 44
  • 83