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 );
	}
示例#2
0
		/// <summary>
		/// 将目前所有的脚本输出.
		/// </summary>
		/// <param name="key">脚本块的关键字.</param>
		public void WriteScript ( string key = null )
		{

			if ( this.code == string.Empty )
				return;

			ScriptHelper script = new ScriptHelper ( );
			script.AppendCode ( this.code );
			script.Build ( new RazorScriptHolder ( this.page ), key );
			this.code = string.Empty;
		}
	protected void cmdRun2_Click ( object sender, EventArgs e )
	{
		// 创建 ScriptHelper 对象
		ScriptHelper scriptHelper = new ScriptHelper ();
		string code = this.txtCode2.Text;

		if ( code == string.Empty )
		{
			// 没有脚本, 添加弹出消息框的脚本
			scriptHelper.Alert ( "'没有任何脚本'" );
			scriptHelper.Build ( this, option: ScriptBuildOption.Startup );
			return;
		}

		ScriptHelper.RegisterAttribute ( this, this.lblCode2.ClientID, "innerText", code );
		scriptHelper.AppendCode ( code );

		// 生成脚本到页面
		scriptHelper.Build ( this, option: ScriptBuildOption.Startup );
	}
示例#4
0
		protected override void Render ( HtmlTextWriter writer )
		{

			if ( !this.Visible )
				return;

			if ( this.isFaceless ( ) )
				writer.Write ( "<span style=\"font-family: Verdana; background-color: #FFFFFF; font-size: 10pt;\"><strong>{0}:</strong> {1}</span>", "AjaxManager", this.ID );

			if ( this.DesignMode )
				return;

			ScriptHelper script = new ScriptHelper ( );

			//!+ The following code is similar with AutocompleteSetting.Recombine, WidgetSetting.Recombine

			foreach ( AjaxSetting ajax in this.ajaxs )
				if ( !string.IsNullOrEmpty ( ajax.ClientFunction ) )
				{
					string data;

					if ( string.IsNullOrEmpty ( ajax.MethodName ) )
						data = "data";
					else
						// According to the .NET version to determine the location of JSON
						if ( Environment.Version.Major <= 2 || ( Environment.Version.Major == 3 && Environment.Version.Minor == 0 ) )
							data = "data";
						else
							data = "data.d";

					if ( !string.IsNullOrEmpty ( ajax.Success ) )
						ajax.Success = ajax.Success.Replace ( "-:data", data );

					if ( !string.IsNullOrEmpty ( ajax.Complete ) )
						ajax.Complete = ajax.Complete.Replace ( "-:data", data );

					if ( !string.IsNullOrEmpty ( ajax.Error ) )
						ajax.Error = ajax.Error.Replace ( "-:data", data );

					JQuery jquery = JQueryUI.Create ( ajax );

					if(null != jquery)
						script.AppendCode ( "function " + ajax.ClientFunction + "(" + ajax.ClientParameter + ") {" + jquery.Code + "}" );

				}

			script.Build ( new ASPXScriptHolder ( this ), this.ClientID, ScriptBuildOption.Startup );
		}