| 小解c#中运行js代码实例 |
| 来源:
发布时间:2008-09-01 发布人:
浏览:
人次
字体:
[大
中
小]
|
|
本文要实现的这个功能是在c#中运行js代码,把js代码放在后台写,看下面示例: using System; using System.Collections.Generic; using System.Text; using MSScriptControl; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { ScriptControlClass script;
script = new ScriptControlClass();
script.Language = "JScript";
script.Reset();
script.AddCode(@"String.prototype.trim=function (){return this.replace(/(^\s*)|(\s*$)/g,'');};var s='ss';");
object result = script.Eval("' fdsafds fds '.trim()");
Console.WriteLine(result);
result = script.Eval("s;");
Console.WriteLine(result);
Console.Read(); } } }
| |
| |
|
|
|
|
| §最新评论:(评论内容只代表网友观点,与本站立场无关!) | |
|
|
|
|
| 注意:请勿在本站发布政治话题、色情及违反法律的内容。 |
IT知道网 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。 |