正在阅读:初次体验.net Ajax无刷新技术初次体验.net Ajax无刷新技术

2005-09-22 10:14 出处: 作者:代码乱了,不知道该怎么办 责任编辑:moningfeng

  3.新建一个类DemoMethods,这个类实现获取客户端MAC地址:

using System;
using System.Web;

namespace AjaxSample
{
/**//// <summary>
/// Summary description for Methods.
/// </summary>
public class DemoMethods
{

[Ajax.AjaxMethod]
public string GetCustomerMac(string clientIP) //这里输入客户端IP,这个函数知识测试用,你也可以写一个其他的简单一点的函数代替
{
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 mac.Replace("-", "").Trim();
}
}

}


  4.写javascript,新建一个名为default.js文件如下

function GetMac()
{
var clientIP="192.168.0.1";
//document.getElementById("Mac").value=DemoMethods.GetCustomerMac(clientIP).value
alert(DemoMethods.GetCustomerMac(clientIP).value);
}

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品