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

📄 demo.cs

📁 ajax的应用实例 是个很好的学习例子 对初学者用很打帮助
💻 CS
字号:
using System;
using System.Data;
using AjaxPro;

namespace AJAXDemo.Examples.DataSets
{
	public class Demo
	{
		public Demo()
		{
		}

		/// <summary>
		/// This method will return a DataSet that is saved on the web servers hard disk.
		/// </summary>
		/// <returns>Returns a DataSet.</returns>
		[AjaxMethod]
		public DataSet GetDataSet()
		{
			DataSet ds = new DataSet();

			ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("~/Examples/DataSets/dataset.xml"), XmlReadMode.ReadSchema);

			return ds;
		}

		/// <summary>
		/// This method will read from the master database on your local SQL server. Please modify 
		/// the connection string if you want to use a different server.
		/// </summary>
		/// <returns>Returns a DataSet.</returns>
		[AjaxMethod]
		public DataSet GetSqlServerTable()
		{
			DataSet ds = new DataSet();
			System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection("server=(local);Trusted_connection=yes;database=master;");
			System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("SELECT top 5 uid, name, type, refdate FROM sysobjects", conn);

			try
			{
				conn.Open();
			
				try
				{
					da.Fill(ds);
				}
				finally
				{
					conn.Close();
					conn.Dispose();
				}
			}
			catch(Exception)
			{
			}

			return ds;
		}

		/// <summary>
		/// This method will return the XML behind the DataSet. This example will be used to
		/// get a DataSet from the client-side JavaScript.
		/// </summary>
		/// <param name="ds">The DataSet.</param>
		/// <returns>A string representating the XML structure of the DataSet.</returns>
		[AjaxMethod]
		public string GetXmlFromDataSet(DataSet ds)
		{
			return ds.GetXml();
		}
	}
}

⌨️ 快捷键说明

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