protected void cmdOK4_Click ( object sender, EventArgs e ) { // 创建 ScriptHelper 对象 ScriptHelper scriptHelper = new ScriptHelper (); // 声明用于存储颜色值得数组 ScriptHelper.RegisterArray ( this, "colors", "10, 99, 10" ); // 添加可以得到不同颜色的函数 scriptHelper.AppendCode ( "function GetNextColor(){colors[0]++;colors[1]--;colors[2]+=2;if(colors[0]>99){colors[0]=10;}if(colors[1]<10){colors[1]=99;}if(colors[2]>99){colors[2]=10;}return '#' + colors[0].toString() + colors[1].toString() + colors[2].toString(); }" ); // 设置时钟, 改变标签的颜色 scriptHelper.SetInterval ( "function(){document.getElementById('span4').style.color = GetNextColor();}", 100 ); // 生成脚本 scriptHelper.Build ( this, option:ScriptBuildOption.Startup ); }
protected void cmdTestClearTimeout_Click ( object sender, EventArgs e ) { string result = string.Empty; Tracer tracer = new Tracer (); ScriptHelper scriptHelper = new ScriptHelper (); result += "测试方法 ScriptHelper.ClearTimeout(string)<br />"; scriptHelper.SetInterval ( "'alert(\"句柄 timer1\");'", 5000, "timer1" ); foreach ( object code in tracer.Execute ( scriptHelper, null, "ClearTimeout", FunctionType.Method, new Type[] { typeof ( string ) }, null, null, null, new object[][] { new object[] { "timer1" }, }, false ) ) result += "返回: " + code.ToString () + "<br />"; result += "测试方法 ScriptHelper.ClearTimeout(string, bool)<br />"; scriptHelper.SetInterval ( "'alert(\"句柄 timer2\");'", 5000, "timer2" ); foreach ( object code in tracer.Execute ( scriptHelper, null, "ClearTimeout", FunctionType.Method, new Type[] { typeof ( string ), typeof ( bool ) }, null, null, null, new object[][] { new object[] { "timer2", false } }, false ) ) result += "返回: " + code.ToString () + "<br />"; result += "scriptHelper.Code = " + scriptHelper.Code + "<br />"; this.lblResult.Text = result; scriptHelper.Build ( this ); }