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

📄 demomethods.cs

📁 ajax是未来之星
💻 CS
字号:
// *******************************************************************************************
//
// Ajax.NET Professional - The free AJAX implementation for the Microsoft.NET Framework
//
// Copyright (C) 2005 Michael Schwarz, info@schwarz-interactive.de
//
// *******************************************************************************************
using System;

namespace AjaxProSample.NamespaceTest.Demo
{
	/// <summary>
	/// Summary description for DemoMethods.
	/// </summary>
	public class DemoMethods
	{
		[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
		public void Test5(string s)
		{
			System.Web.HttpContext.Current.Session["example"] = s;
		}

		[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
		public string Test6()
		{
			if(System.Web.HttpContext.Current.Session["example"] != null)
				return (string)System.Web.HttpContext.Current.Session["example"].ToString();

			return "First set the value...";
		}

		[AjaxPro.AjaxMethod]
		public DateTime GetServerTime()
		{
			return DateTime.Now;
		}

		[AjaxPro.AjaxMethod]
		public DateTime PutServerTime(DateTime d)
		{
			return d;
		}

		[AjaxPro.AjaxMethod]
		public string GetDateStringOnServer(DateTime d)
		{
			return d.ToString();
		}

		[AjaxPro.AjaxMethod]
		public string PutTwoServerTimes(DateTime d1, DateTime d2)
		{
			return d1.ToString() + "\r\n" + d2.ToString();
		}

		[AjaxPro.AjaxMethod]
		public IPerson GetPerson(int id)
		{
			if(id == 1)
			{
				IPerson b = new IPerson();

				b.FirstName = "Tanja";
				b.FamilyName = "Schwarz";
				b.Age = 25;
				b.Gender = GenderType.Female;

				return b;
			}

			IBoss p = new IBoss();

			p.FirstName = "Michael";
			p.FamilyName = "Mustermann";
			p.Age = 28;
			p.Company = "My Company GmbH Co.KG";
			p.Gender = GenderType.Male;

			return p;
		}

		[AjaxPro.AjaxMethod]
		public bool IsBoss(IPerson p)
		{
			return p.GetType() == typeof(IBoss);
		}
	}

	[AjaxPro.AjaxClass]
	public class IPerson
	{
		public string FirstName;
		public string FamilyName;
		public int Age = 0;
		public GenderType Gender = GenderType.Unknown;
	}

	public class IBoss : IPerson
	{
		public string Company;
	}

	public enum GenderType
	{
		Male,
		Female,
		Unknown
	}
}

⌨️ 快捷键说明

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