javascript.cs

来自「为武汉市10多家人才网站量身订做的仿真面试版块」· CS 代码 · 共 100 行

CS
100
字号
using System;
using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace Job111
{
	/// <summary>
	/// JavaScript 的摘要说明。
	/// </summary>
	public class JavaScript
	{
		public static void ShowMessageBox(Page p, string message)
		{
			string HtmlCode = "";
			HtmlCode += "<script language = javascript>alert('" + message +"')</script>";
			p.Response.Write(HtmlCode);
		}

		public static void ShowMessageBox(Page p, string message, int backStep)
		{
			string HtmlCode = "";
			HtmlCode += "<script language = javascript>alert('" + message +"');history.back(" + backStep.ToString() + ")</script>";
			p.Response.Write(HtmlCode);
		}

		public static void Preview(HtmlContainerControl ctrl, string Url)
		{
			string HtmlCode = "";
			HtmlCode += "<tbody><iframe src = '" + Url +"'>";
			HtmlCode += "</iframe></tbody>";
			ctrl.InnerHtml = HtmlCode;
		}

		public static void CloseWindow(Page p)
		{
			string HtmlCode = "<script language = javascript>window.close()</script>";
			p.Response.Write(HtmlCode);
		}

		public static void ShowModeLessDialog(HtmlContainerControl ctrl, string Url)
		{
			string HtmlCode = "";
			HtmlCode += "<Script language = javascript>window.showModelessDialog('" + Url + "');history.back(-1)</script>";
			ctrl.InnerHtml = HtmlCode;
		}

		public static void ShowModeDialog(HtmlContainerControl ctrl, string Url)
		{
			string HtmlCode = "";
			HtmlCode += "<Script language = javascript>window.showModeDialog('" + Url + "')</script>";
			ctrl.InnerHtml = HtmlCode;
		}

		public static void NewWindow(HtmlContainerControl ctrl, string Url)
		{
			string HtmlCode = "";
			HtmlCode += "<script language = javascript>window.open('" + Url +"')</script>";
			ctrl.InnerHtml = HtmlCode;
		}

		public static void NewWindow(Page p, string Url)
		{
			string HtmlCode = "";
			HtmlCode += "<script language = javascript>window.open('" + Url +"')</script>";
			p.Response.Write(HtmlCode);
		}

		public static void ShowObject(HtmlContainerControl ctrl, string Url, int width, int height)
		{
			string HtmlCode = "";
			HtmlCode += "<object width = " + width.ToString() + " height = " + height.ToString() + " data = " + Url + " type = text/html></object>";
			ctrl.InnerHtml = HtmlCode;
		}

		public static void ChangePage(Page p, string Url)
		{
			string HtmlCode = "";
			HtmlCode += "<script language = javascript>location.href = '" + Url + "'</script>";
			p.Response.Write(HtmlCode);
		}

		public static void Confirm(Page p, string Msg, string TrueUrl, string FalseUrl)
		{
			p.Response.Write("<script language = javascript>");
			p.Response.Write("var result = confirm('" + Msg + "');");
			if(TrueUrl != "")
			{
				p.Response.Write("if(result) ");
				p.Response.Write("{location.href = '" + TrueUrl + "';}");
			}
			if(FalseUrl != "")
			{
				p.Response.Write("if(!result)");
				p.Response.Write("{location.href = '" + FalseUrl + "';}");
			}
			p.Response.Write("</script>");
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?