[תÌû]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() {
Ïà¹ØÎĵµ£º
ÔÚasp.netÖÐÉú³ÉhtmlÎļþ´úÂëÈçÏÂ
public static bool CreatHtmlPage(string[] strNewsHtml, string[] strOldHtml, string strModeFilePath, string strPageFilePath)
{
bool Flage = false;
......
1. Asp.NetÖм¸ÖÖÏàËƵıê¼Ç·ûºÅ: < %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Container.DataItem("tit") %>
< %= %>: ÔÚ³ÌÐòÖ´ÐÐʱ±»µ÷Ó㬿ÉÒÔÏÔʾºǫ́±äÁ¿Öµ
Èç:
*.aspxÖУº < %= ......
1¡¢Èç¹ûÕâÖÖÇé¿ö³öÏÖÔÚ±¾»ú£¬ÔòÔÚsql server µÄÆóÒµ¹ÜÀíÆ÷µÄ¿ØÖÆ̨Ŀ¼ÀïÑ¡ÔñÏàÓ¦µÄÊý¾Ý¿â£¬ÔÚÆäϵÄÓû§½ÚµãµãÓÒ¼üн¨Êý¾Ý¿âÓû§£¬½«***\ASPNETÓû§¼ÓÈ룬²¢¸³ÓèpublicȨÏÞ¡£
2¡¢Èç¹û³öÏÖÔÚÆäËûµÄµçÄÔ£¬Ôò¼ì²é ³ÌÐòÁ¬½ÓSQLServerµÄÁ¬½Ó×Ö·û´®ÊDz»ÊÇÓÃÁËwindows¼¯³ÉµÇ½£¬Ò»°ã³öÏÖ´ËÎÊÌâµÄ×´¿ö¶¼ÊÇÒòΪʹÓÃÁËwindows¼¯³Éµ ......
·¨Ò»£ºµ÷ÓÃwinrar
using Microsoft.Win32;
using System.Diagnostics;
protected void Button1_Click(object sender, EventArgs e)
{
RAR(@"E:\95413594531\GIS", "tmptest", @"E:\95413594531\");
}
/// < ......
µ± ASP.NET ½ÓÊÕÕë¶ÔÒ³µÄÇëÇóʱ£¬Ëü´ÓÏ̳߳ØÖÐÌáÈ¡Ò»¸öÏ̲߳¢½«ÇëÇó·ÖÅä¸ø¸ÃÏ̡߳£
Ò»¸öÆÕͨµÄ£¨»òͬ²½µÄ£©Ò³ÔÚ¸ÃÇëÇóÆڼ䱣ÁôỊ̈߳¬´Ó¶ø·ÀÖ¹¸ÃÏß³ÌÓÃÓÚ´¦ÀíÆäËûÇëÇó¡£Èç¹ûÒ»¸öͬ²½ÇëÇó³ÉΪ I/O bound£¨ÀýÈ磬Èç¹ûËüµ÷ÓÃÒ»¸öÔ¶³Ì Web ·þÎñ»ò²éѯһ¸öÔ¶³ÌÊý¾Ý¿â£¬²¢µÈ´ýµ÷Ó÷µ»Ø£©£¬ÄÇô·ÖÅä¸ø¸ÃÇëÇóµÄÏß³ÌÔÚµ÷Ó÷µ»Ø֮ǰ´ ......