demomethods.cs

来自「实际是NET使用AJAX的学习例子.为使用AJAX初学的同志.提供入门帮助与学习」· CS 代码 · 共 73 行

CS
73
字号
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
/// <summary>
/// DemoMethods 的摘要说明
/// </summary>
public class DemoMethods
{
	public DemoMethods()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    [Ajax.AjaxMethod]
    public string GetCustomerMac(string clientIP)
    {
        string mac = "";
        System.Diagnostics.Process process = new System.Diagnostics.Process();
        process.StartInfo.FileName = "nbtstat";
        process.StartInfo.Arguments="-a"+clientIP;
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.CreateNoWindow = true;
        process.StartInfo.RedirectStandardOutput = true;
        process.Start();
        string output = process.StandardOutput.ReadToEnd();
        int length = output.IndexOf("MAC Address = ");
        if (length > 0)
        {
            mac = output.Substring(length + 14, 17);  
        }
        process.WaitForExit();
        return clientIP;
    }
    [Ajax.AjaxMethod]
    public DataSet getdataset()
    {
        DataTable table = new DataTable();
        DataColumn column = new DataColumn();
        string row = "sample";
        table.Columns.Add(column);
        table.Rows.Add(row);
        column.ColumnName = "firstname";
        DataSet ds = new DataSet();
        ds.Tables.Add(table);
        return ds;
    }
    [Ajax.AjaxMethod]
    public string GetXML()
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<state>");
        sb.Append("<city>北京</city>");
        sb.Append("<city>上海</city>");
        sb.Append("<city>大连</city>");
        sb.Append("<city>天津</city>");
        sb.Append("</state>");

        return sb.ToString();
       
       
        
    }
}

⌨️ 快捷键说明

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