初次体验.NET Ajax无刷新技术
1. 新建一个项目,在引用中添加引用Ajax.dll,Ajax.dll位于下载的压缩包里面。
2.建立HttpHandler,在web.config里面加上 <configuration> 3.新建一个类DemoMethods,这个类实现获取客户端MAC地址:
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
...
<system.web>
</configuration> using System;
using System.Web;
namespace AjaxSample
{
///
/// Summary description for Methods.
///
public class DemoMethods
{
[Ajax.AjaxMethod]
public string GetCustomerMac(string clientIP) //para IP is the client's 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);
}
5.在某个Aspx页面放上一个html 的button
在页面上 中引用default.js :
在INPUT的onclick事件中加上onclick="ja
[1] [2] 下一页
- 最新文章
- 创建优秀网页的6个好习惯[01-18]
- WEB设计经验[01-18]
- 制作主页的“五十”大秘诀[01-18]
- 学习Web 2.0的方向盘[01-18]
- 网站设计必须知道的65条原则[01-18]
- AJAX的七宗罪[01-18]
- 相关文章
- AJAX的七宗罪[01-18]
- 驳“AJAX 的七宗罪”[01-18]
- 一个使用J2ME技术实现的简单计算器[01-11]
- 使用J2ME MMAPI开发移动多媒体应用技术[01-11]
- J2EE探索:有状态网络的J2EE技术[01-11]
- J2EE基础:使用JSF技术开发Web应用程序[01-11]
