大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 网页设计 -> 其他相关 -> 初次体验.NET Ajax无刷新技术

初次体验.NET Ajax无刷新技术

时间: 2021-07-31 作者:daque

早就传闻ajax本领了,传闻中是一种很牛的货色,号称无革新,本来是在web上经过javascript,运用异步的xmlhttp乞求,实行无革新的web界面。怅然从来没有领会过, 先后听做php的伙伴用过php的ajax开拓包,并且做了很多很酷的货色,使娃娃生向往不已。 今世界了一个.net ajax开拓包,该开拓包囊括asp2.0和暂时asp1.1版运用的ajax,精细地方拜见http://ajax.schwarz-interactive.de/,接下来,动工。    1. 兴建一个名目,在援用中增添援用ajax.dll,ajax.dll坐落载入的收缩包内里。

   2.创造httphandler,在web.config内里加上 <configuration> <system.web> <httphandlers> <add verb="post,get" path="ajax/*.ashx" type="ajax.pagehandlerfactory, ajax" /> </httphandlers> ... <system.web> </configuration> 3.兴建一个类demomethods,这个类实行获得存户端mac地方: 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="javascript:getmac()"

value="存户端获得ip" onclick="javascript:getmac();">

   6.窜改global.asax的application_start事变,树立ajax的handlerpath :

protected void application_start(object sender, eventargs e) { ajax.utility.handlerpath = "ajax"; }

运转看看功效。是否没有革新就在效劳器端取到存户端的mac地方??

须要提防的是:该本子的.net ajax须要细工在中global.asax加上ajax.utility.handlerpath = "ajax"; 摆设文献web.config必需加上httphandler的摆设消息!

该开拓包的新本子还没有赶得及领会,估量新本子中会简单少许,大概会去掉手动的树立global.asax的application_start事变中加上ajax.utility.handlerpath = "ajax";以及其余烦恼的树立!憧憬ing……

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.