AJAX ÑéÖ¤Óû§
1´´½¨Á½ÕÅÒ³Ãæ Reg.aspx¡¢CallServer.aspx¡£
ÔÚReg.aspxÒ³ÃæµÄhtmlÖзŠһ¸ö²ãºÍÒ»¸öÎı¾¿ò
<div id="aa">
<asp:TextBox id="txtuser" runat="server" Width="136px"></asp:TextBox>
</div>
<span id="errInfo">ÇëÊäÈëÓû§Ãû</span>
ÔÚReg.aspxÒ³ÃæÖÐдjavascript
¶¨Òå¶þ¸ö±äÁ¿ ¡¢Èý¸öº¯Êý
var xmlhttp=false; //·Å ActiveXObjectµÄʵÀý
var NewsInfo=""; //·Å ×Ö·û´®
function GetXmlHttp()
...{
if(window.ActiveXObject)
...{
try
...{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP.3.0");
}
catch(e)
...{
try
...{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
...{
NewsInfo="·þÎñÆ÷æ...";
}
}
}
return xmlhttp;
}
function CallServer()
...{
GetXmlHttp();
var struser=document.getElementById("txtuser").value;
if(struser=="" || struser==null)return;
var url="CallServer.aspx?user="+escape(struser);
xmlhttp.onreadystatechange=CallBack;
xmlhttp.open("post",url,true);
xmlhttp.send();
}
function CallBack()
...{
if(xmlhttp.readyState==1)
...{
NewsInfo="Loading...";
}
if(xmlhttp.readyState==4)
...{
var msg=xmlhttp.reponseText;
var spanid=document.getElementById("errInfo");
spanid.innerHTML=msg;
}
}
2ÔÚCallServer.aspxÒ³ÃæµÄpage_loadÖÐдÈçÏ´úÂë
SqlConnection conn=new SqlConnection("server=
Ïà¹ØÎĵµ£º
ÓкܾÃÒ»¶Îʱ¼äÎÒµÄBLOGÉÏûÓгöÏÖAJAXÏà¹ØÑ¶Ï¢ÁË£¬Ö÷Òªµ±È»ÊÇÒòΪ¾ø´ó²¿·ÖµÄÖØÐͼ·Åµ½ÁËSilverlightÉíÉÏ(¿ÉÔ¤ÆÚµÄδÀ´Ó¦¸ÃÒ²»áÊÇÈç´Ë)¡£
µ«ÓÉÓÚ¹¤×÷ÉϵÄÐèÒª£¬×î½ü»¹ÊÇ»ØÍ·¿´ÁËһϼ´½«ÍƳöµÄASP.NET Ajax Library...£¬Ë³±ãÕÒÁËÒ»ÏÂÍøÂçÉϵÄѶϢ£¬¿´Õâ¸öÌ¬ÊÆÎÒ²ÂÏëÓ¦¸Ã²»ÉÙASP.NET¿ª·¢ÈËÔ±ºöÂÔµôÁËÕâ¸öÆäʵÒѾbet ......
1¡¢Ô´´úÂë
Õâ¸öAJAXÁ¬½Ó³Øº¦ÎÒÎÒŪÁ˺ܾã¬ÖÕÓÚ£¬ÈÃËü¼æÈÝIE6/7/8¡¢FireFox¡¢Opera¡¢Google ChromeÕâËÄÀàä¯ÀÀÆ÷ÁË¡£
/**
* AJAX Á¬½Ó³Ø
* AJAXConnectionPool Build in 2009.7.10
* @author CodingMouse
* @version 1.0
*/
var AJAXConnectionPool = function() {
// ÈÎÎñ¶ÓÁÐ
var taskQ ......
ÔÚAjax url´«²Îʱ³öÏÖÖÐÎÄÂÒÂëµÄÇé¿ö
Àý1: xmlHttp.open("GET","Engine.aspx?Action=getmainsort&Type=2&Parent="+escape("ÖÐÎÄ")+"&Stochastic=" + Math.random(),true);
µ«ÊÇÕâ¸öÖ»ÄÜÆÕͨµÄ<a href=''.ÓÐЧ¹û¡£Èç¹ûÊÇajax´«ÖµµÄ»°»¹ÊDz»ÐеÄ...ÓÐÈËÌá³ö:Òª ......
´´½¨ÓÃÓÚ±£´æÍ¼Æ¬µÄ±í£º
create table stockImages
( imageid int primary key identity(1,1),
[filename] varchar(50),
img varbinary(max))
²åÈë±¾µØÍ¼Æ¬£º
insert into stockImages
select '·ç¾°',bulkcolumn
from openrowset(bulk 'd:\\img.jpg',single_blob) as x
´´½¨´æ´¢¹ý³Ì£¬¼ìË÷ͼƬ£¬½«¶ ......