ASP.NET AJAXµ÷ÓÃWebService
ÈçºÎÔÚ¿Í»§¶ËÖ±½Óµ÷ÓÃWebServiceÖеķ½·¨£¿
ÕâÀï½áºÏ¾Ñé×Ô¼ºÐ´Ò»Ð´
1.Ê×ÏÈн¨Ò»¸ö ASP.NET AJAX-Enabled Web Site,ÕâÑùϵͳΪÎÒÃÇ×Ô¶¯ÅäÖúÃÁË»·¾³£¬ÕâÖ÷ÒªÌåÏÖÔÚWeb.configÕâ¸öÎļþÉÏ£¬Èç¹ûÒÑÓÐÍøÕ¾²»ÊÇASP.NET AJAX-Enabled Web SiteÒ²¿ÉÒÔ¶ÔÕÕÐÞ¸ÄÏÂWeb.config£¬Ò²¿ÉÒÔ´ïµ½ÏàͬµÄЧ¹û¡£
2.н¨Ò»¸öweb·þÎñ£¬WebService.asmx£¬ÔÚWebService.csÐèÒªÌí¼ÓSystem.Web.Script.Services;Õâ¸öÃüÃû¿Õ¼ä£º
using System.Web.Script.Services;
È»ºó¸øWebService ÀàÌí¼Ó[ScriptService]ÊôÐÔÕâÀïÏÈ˵²½Ö裬ºóÃæ˵ÔÀí£¬È»ºó¸øÎÒÃÇÐèÒªµ÷Óõķ½·¨¼ÓÉÏ
[WebMethod]ÊôÐÔ
3.н¨Ò»¸öJScriptÎļþ£¬JScript.js£¬ÀïÃæÓÃÀ´ÏìÓ¦½çÃæʼþ´¦Àí»Øµ÷·½·¨·µ»ØµÄÊý¾Ý
4.н¨Ò»¸öÒ³ÃæDefault.aspx,Èç¹ûÊÇASP.NET AJAX-Enabled Web SiteÒ³ÃæÉÏ»á×Ô¶¯Ìí¼ÓScriptManager¿Ø¼þ£¬Èç¹û²»ÊÇÖ»ÒªÊÖ¹¤ÍÏÉÏÈ¥Ò»¸ö£¬È»ºó¸øScriptManagerÌí¼ÓScript½Úµã£¬Õâ¸ö½ÚµãÓÃÀ´Ö¸¶¨ÒªÊ¹ÓõÄjsÎļþ
<Scripts><asp:ScriptReference Path="~/JScript.js" /></Scripts>
ÔÙ¸øScriptManagerÌí¼ÓServices½Úµã£¬Õâ¸ö½ÚµãÓÃÀ´Ö¸¶¨ÒªÊ¹ÓõÄWebService
<Services><asp:ServiceReference Path="~/WebService.asmx" /></Services>
ÕâЩ¹¤×÷Íê³ÉºóÖ»ÒªÔÚ½çÃæÉÏij¸ö¿Ø¼þ»òÕßij¸öµØ·½µ÷ÓÃÎÒÃǵÄjs·½·¨¾Í¿ÉÒÔÁË¡£
˵µÄÊǵ÷Óñ¾µØµÄWebService,Èç¹ûÊǵ÷ÓÃÍøÉϵÄWebService,ÔÀíÒ²ÊÇÒ»Ñù£¬²»¹ýÐèÒªÌí¼Óµã¶«Î÷£¬¾ÍÄÓһЩ³£ÓõÄWebServices”ÖеĵÚÒ»¸öWebServiceÀ´Ëµ°É£¬ÌìÆøÔ¤±¨Web·þÎñ£¬ÔÚÍøÕ¾ÉÏÌí¼ÓwebÒýÓã¬
ÔÚurlµØÖ·ÖÐÌîÈëµØÖ··þÎñµØÖ·£¬Ç°Íù£¬È»ºóÌí¼ÓÒýÓþͿÉÒÔÁË£¬ÆäËü´¦ÀíºÍ±¾µØÒ»Ñù¡£
ÌùһϴúÂ룬°üÀ¨±¾µØµÄweb·þÎñºÍÔ¶³Ìweb·þÎñ
I.Default.aspx´úÂ룺
<html xmlns="[color=#000000]http://www.w3.org/1999/xhtml[/color]">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" >
<Scripts>
Ïà¹ØÎĵµ£º
ÔÚWeb.configÎļþµÄ <system.web></system.web>ÕâÁ½¸ö½ÚµãÖмä²åÈëÐèÒªÓ³ÉäµÄURL
<urlMappings enabled="true">
<add url="~/Óû§Òª·ÃÎʵÄÒ³Ãæ.aspx" mappedUrl="~/ÒªÖض¨Ïòµ½µÄÒ³Ãæ.aspx"/>
</urlMappings> ......
protected void Page_Load(object sender, EventArgs e)
...{
this.btnOK.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btnOK, "Click") + ";this.disabled=true; this.value='Ìá½»ÖÐ...';");
}
//°´Å¥´¦Àí·½·¨
protected void btnOK_C ......
Form ±íµ¥£ºÒ»¸öÒ³ÃæÖ»ÄÜÓÐÒ»¸ö
runat=“server”²»ÊDZØÐëµÄ£¬¼ÓÉϺ󣬻áÔÚÊä³öµÄÔ´´úÂëÀï¶àÁËÒ»ÐÐ
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGR/8ZxOm5Tn0sfHNJaqE12hKqqJTQ==" />
ºÙ£¬Õâ²»¾ÍÊÇ´«ËµÖеÄviewstateÂð¡£ÔÀ´Õâ¾ÍÊÇ.netÖеÄFORM¸úHTMLÖÐF ......
System.Windows.Forms;
FolderBrowserDialog ÌṩÁËÎÒÃÇÐèÒªµÄÎļþ¼Ðä¯ÀÀ¶Ô»°¿ò£¬ÒòΪÊÇCOM±ØÐëÊÇSTAµÄ£¬ÉèÖà AspCompat="true"À´½â¾öÕâ¸öÎÊÌâ¡£
Ó÷¨£º
protected void Button1_Click(object sender, EventArgs e)
{
  ......
ÔÚASP.NETÖÐʹÓÃTreeview¿Ø¼þºÍXML
ÒÔÇ°£¬ÔÚWEBÒ³ÃæÖÐÈç¹ûÏëʹÓÃÊ÷ÐοؼþµÄ»°£¬ÍùÍù»áÓÐЩÂé·³£¬ÓÐʱÉõÖÁÒª×Ô¼ºÐ´´úÂëÀ´´ïµ½ÓÃÊ÷ÐÎÁбíÏÔʾÊý¾ÝµÄÄ¿µÄ¡£ÔÚasp.netÖУ¬ÎÒÃÇ¿ÉÒԺܷ½±ãµØʹÓÃÓÉ΢ÈíÌṩµÄInternet Exploer Web Controls¿Ø¼þÀ´ÊµÏÖÊ÷ÐÎÁÐ±í¡£ÔÚ΢ÈíÌṩµÄÕâÌ×Internet Exploere Web Controls¿Ø¼þ¼¯ºÏÖУ¬°üÀ ......