I have a code editor written in JavaScript on my page and I want to send the code that it is typed in as a string to IronPython so that it can be executed from IronPython. I got this to work in C# but not in IronPython. Below is the JavaScript I use:
<script type="text/javascript"> var textarea = document.getElementById('code'); var editor = new CodeMirror(CodeMirror.replace (textarea), { height: "350px", width: "500px", content: textarea.value, parserfile: ["tokenizejavascript.js", "parsejavascript.js"], stylesheet: "css/jscolors.css", path: "js/", autoMatchParens: true }); function invokeManagedCode() { var form = document.getElementById("editor"); var user = form.user.value; var control = document.getElementById("sl2"); control.Content.codeProvider.Code(editor.getCode ()); } </script> The code replaces a standard HTML-textarea with the JavaScript editor. The function "invokeManagedCode()" sends the text in the code editor to a C# method. The C# code is really simple: namespace htmlDom1 { public partial class Page : UserControl { public Page() { InitializeComponent(); HtmlPage.RegisterScriptableObject("codeProvider", this); } [ScriptableMember()] public void Code(string codeString) { this.Message.Text = codeString; } } } How can I achieve the same in IronPython? I tried to do exactly the same as in C#. See below: [ScriptableMember()] def Code(codeString): root.sl2TextBox.Text = codeString # Show that it works by writing the string # from the javascript code editor to a Silverlight textbox HtmlPage.RegisterScriptableObject("codeProvider", Code) But this doesn't work. How to do it properly? Thanks for help! _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com