[תÌû]asp.net Ajax ÖÕ¼«½â¾ö·½°¸
ajax ÔÚÄ¿Ç° web ÁìÓòÒѹ㷺ӦÓã¬ÆäÕæÕýºËÐÄÖ»²»¹ýÊÇÒ»¸ö·â×°ºÃÁ赀 js ¿â¡£×îÎ廨°ËÃŵÄĪ¹ýÓÚ asp.net µÄ¿Ø¼þ£¬ÎÒ¸öÈËÈÏΪ ajax Ö»ÊÇÒ»¸öÇáÁ¿¼¶µÄ¶«Î÷£¬¸ù±¾Ã»ÓбØÒª½«Ëüд³É·þÎñÆ÷×é¼þ£¬Èç ajax.net¡¢AjaxControlToolkit µÈ¡£ËùÒÔÎÒÒ»Ö±ÊÓÕâЩ×é¼þΪÀ¬»ø¡£¡£¡£
ÒÔÏÂ˵Ã÷ÎÒΪʲô²»ÈÏͬ ajax µÄÏà¹Ø×é¼þ£º
1¡¢½« ajax ·â×°µÃÌ«ËÀ£¬³öÏÖÎÊÌâÄÑÓÚµ÷ÊÔ£»
2¡¢×é¼þ¹ýÓÚÓ·Ö×£¬Ì«¶àûÓÐÓõŦÄÜ£»
3¡¢ÒÀÀµÐÔÌ«Ç¿£¬ÉÙÒ»Ñù²»¿É£¬Èç webform£»
´«Í³µÄ ajax Ó¦Óõ½ÏîÄ¿ÖУ¬»á³öÏÖÓÉÓÚÏîÄ¿µÄ ajax Ó¦ÓÃÌ«¶à£¬·þÎñ¶ËµÄ ajax ÏìÓ¦º¯ÊýÄÑÓÚ¹ÜÀí£¬ÎÒÃǵ½µ×Òª°ÑÕâЩÏìÓ¦º¯Êý²¿ÊðÔÚʲôλÖã¿
¼ÙÈç
index.aspx ÀïÓÐÈý¸ö ajax ÏìÓ¦º¯Êý£¬ÎÒÃÇ¿ÉÒÔ°ÑÕâÈý¸öÏìÓ¦º¯Êý·ÅÔÚ index.aspx ÖУ¬²¢ÓÚ Page_Load ʼþÖиù¾Ý²ÎÊý²»Í¬À´µ÷ÓÃÕâЩº¯Êý¡£
index.aspx ÀﻹʹÓÃÁË abc.ascx£¬Õâ¸ö¿Ø¼þÀïÃæÒ²Óõ½ÁË ajax£¬ÄÇô abc.ascx ÀïµÄÏìÓ¦º¯ÊýÓÖÓ¦¸Ã·ÅÔÚÄÄÀindex.aspx ÖÐÂð£¿Èç¹û index2.aspx ÖÐÒ²Óõ½ÁË abc.ascx£¬ÄѵÀ»¹Òª¸´ÖÆ index.aspx µÄ´¦Àíº¯Êýµ½ index2.aspx£¬ÕâÑù¿Ï¶¨²»ÐУ»
ÎÒÃÇ¿ÉÒÔн¨Ò»¸ö ajax.aspx À´´¦ÀíËùÓÐµÄ ajax ÏìÓ¦£¬php/asp ¶¼¿ÉÒÔÕâÑù×ö¡£ÕâÑù¹ÜÀí»¹ÊDz»ÀíÏ룬
×îÀíÏëµÄ¹ÜÀí·½·¨Ó¦¸ÃÊÇÒ³Ãæ¡¢¿Ø¼þÓëÏìÓ¦º¯Êý¼¯³É¡£ICallBackEventHandler ¿ÉÒÔ×öµ½£¬µ«ÊÇËüÒÀÀµ webform£¬¼ÙÈçÄãµÄÒ³ÃæÖÐûÓÐÒ»¸ö £¬Ôò»áʧЧ¡£
ÎÊÌâ»Ø¹éµ½ÈçÌåʹÓÃÇáÁ¿¼¶ ajax£¬²¢ÊµÏÖÒ³Ãæ/¿Ø¼þÓë ajax ÏìÓ¦º¯Êý¼¯³É¡£
Reflector ²é¿´ System.Web.UI.Page ÀïÃæ´¦Àí ICallBackEventHandler Ä£¿éºó£¬ÎÒÃÇ¿ÉÒÔÕâÑù×ö£º
1¡¢ËùÓÐÒ³Ãæ¼Ì³Ð BasePage£»
2¡¢BasePage ¼Ì³Ð System.Web.UI.Page£¬ÖØд BasePage.OnLoad£»
3¡¢ÊµÏÖ AjaxHandler
4¡¢Ìí¼Ó Ajax À࣬ʵÏÖ Ajax.Register ¾²Ì¬·½·¨
´úÂëÈçÏ£º
public class BasePage : Page {
protected override void OnLoad(EventArgs e) {
AjaxHandler();
base.OnLoad(e);
}
ajax handler#region ajax handler
//ÎÒϲ»¶Óà json ¸ñʽÊý¾ÝÀ´·µ»Ø¸ø¿Í»§¶Ë´¦Àí
protected void AjaxHandler() {
Ïà¹ØÎĵµ£º
1.ʲôÊÇAjax?
AjaxµÄÈ«³ÆÊÇ£ºAsynchronous + JavaScript+XML --------------------> Òì²½µÄ(²»Í¬Ê±µÄ) javascript ¼° xml
2.AjaxµÄ¶¨Ò壺
Ajax²»ÊÇÒ»¸ö¼¼Êõ£¬Ëüʵ¼ÊÉÏÊǼ¸ÖÖ¼¼Êõ£¬Ã¿ÖÖ¼¼Êõ¶¼ÓÐÆä¶ÀÌØÕâ´¦£¬ºÏÔÚÒ»Æð¾Í³ÉÁËÒ»¸ö¹¦ÄÜÇ¿´óµÄм¼Êõ¡£
3.Ajax°üÀ¨£º
XHTMLºÍCSS
ʹÓÃÎĵµ¶ ......
·¨Ò»£ºµ÷ÓÃwinrar
using Microsoft.Win32;
using System.Diagnostics;
protected void Button1_Click(object sender, EventArgs e)
{
RAR(@"E:\95413594531\GIS", "tmptest", @"E:\95413594531\");
}
/// < ......
µÚÒ»ÖÖ·½·¨£º
ͨ¹ýURLÁ´½ÓµØÖ·´«µÝ
send.aspx:
protected void Button1_Click(object sender, EventArgs e)
{
Request.Redirect("Default2.aspx?username=honge");
}
receive.aspx:
string user ......
/// <summary>
/// µÃµ½Õ¾µãÓû§IP
/// </summary>
/// <returns></returns>
public
static
string
getUserIP()
{
retu ......