⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mobilewebform1.aspx.cs

📁 专业实例开发
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;

namespace MobileTimeRetriever
{
	/// <summary>
	/// Summary description for MobileWebForm1.
	/// </summary>
	public class MobileWebForm1 : System.Web.UI.MobileControls.MobilePage
	{
		protected System.Web.UI.MobileControls.Label lblCurrentTime;
		protected System.Web.UI.MobileControls.Label lblRegion;
		protected System.Web.UI.MobileControls.SelectionList lstLocations;
		protected System.Web.UI.MobileControls.Command cmdFindTime;
		protected System.Web.UI.MobileControls.Label lblSelLoc;
		protected System.Web.UI.MobileControls.Label lblTime;
		protected System.Web.UI.MobileControls.Command cmdBack;
		protected System.Web.UI.MobileControls.Label lblCurTime;
		protected System.Web.UI.MobileControls.Form frmOptions;
		protected System.Web.UI.MobileControls.Form frmResult;
		protected System.Web.UI.MobileControls.Label lblOrgLoc;

		private void Page_Load(object sender, System.EventArgs e)
		{
			ActiveForm=frmOptions;
			lblCurTime.Text=Convert.ToString(DateTime.Now);
        }

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.cmdFindTime.Click += new System.EventHandler(this.cmdFindTime_Click);
			this.cmdBack.Click += new System.EventHandler(this.cmdBack_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void cmdFindTime_Click(object sender, System.EventArgs e)
		{
			DateTime currentTime= DateTime.Now;
			TimeSpan timeDiff=new TimeSpan(0,0,0);
			switch (lstLocations.Selection.Value)
			{
				case "1":
					timeDiff=new TimeSpan(5,0,0);
					break;
				case "2":
					timeDiff=new TimeSpan(8,0,0);
					break;
				case "3":
					timeDiff=new TimeSpan(12,0,0);
					break;
				case "4":
					timeDiff=new TimeSpan(13,0,0);
					break;
				case "5":
					timeDiff=new TimeSpan(15,0,0);
					break;
			}
            DateTime newTime=currentTime.Add(timeDiff);
			lblSelLoc.Text="You selected: " + lstLocations.Selection.Text;
			lblTime.Text="Time at the selected location:" + Convert.ToString(newTime);
			lblOrgLoc.Text="(as of " + DateTime.Now + " EST)";
			ActiveForm=frmResult;
        }

		private void cmdBack_Click(object sender, System.EventArgs e)
		{
			ActiveForm=frmOptions;
		}

	}
}

⌨️ 快捷键说明

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