asp.net¿Í»§¶Ë½Å±¾µ÷ÓÃÒ³Ãæ·½·¨
µÚÒ»²½£º
½«Ä³¸öÒ³ÃæµÄ·½·¨ ÓÐ webmethod attribute;
[WebMethod]
//Ö»ÄÜÊÇ public static µÄ·½·¨
public static DateTime GetCurrentTime()
{
return DateTime.UtcNow;
}
µÚ¶þ²½£º
Ò³ÃæÓÐÒ»¸öScriptManager ÉèÖÃËüµÄenablepagemethod=true;
asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
µÚÈý²½£ºµ÷ÓÃ
PageMethods.·½·¨Ãû£¨»Øµ÷º¯Êý£©
<mce:script language="javascript" type="text/javascript"><!--
function getCurrentTime()
{
PageMethods.GetCurrentTime(getCurrentTimeSucceeded);
}
function getCurrentTimeSucceeded(result)
{
alert(result);
}
// --></mce:script>
Ïà¹ØÎĵµ£º
1.¹Ø±Õ²»±ØÒªµÄSession
<%@ Page EnableSessionState="flase"%>
2.¹Ø±Õ²»±ØÒªµÄViewState
<asp:DataGrid EnableViewState="false" runat="server">
Èç¹ûÒ³Ãæ¼¶
<%@ Page EnableViewState="false"%>
3.²»ÒªÊ¹ÓÃException¿ØÖƳÌÐòÁ÷³Ì
ExceptionÊǺܺÄ×ÊÔ´µÄ
4.½ûÓÃVBºÍJScript¶¯Ì¬Êý ......
Ч¹ûͼ£º
ǰ̨´úÂ룺
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OWCdrawing.aspx.cs" Inherits="OWCdrawing" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xh ......
ÔÚÕÆÎÕ·þÎñÆ÷¿Ø¼þÉúÃüÖÜÆÚµÄ¹ý³ÌÖУ¬¶ÁÕßÒªÌØ±ð×¢ÒâÓйطþÎñÆ÷¿Ø¼þ״̬µÄÏà¹ØÄÚÈÝ¡£ÔÚÖØµãÁ˽âÉúÃüÖÜÆÚ¸÷¸ö½×¶ÎµÄͬʱ£¬¶Ô·þÎñÆ÷¿Ø¼þµÄ״̬±ä»¯Òª×¢ÒâÒÔÏÂÎÊÌ⣺¿Ø¼þµÄÉúÃüÖÜÆÚºÎʱ±£´æ¿Ø¼þºÍ»Ö¸´Æä״̬£»ºÎʱÓëÒ³Ãæ¼°ÆäËû¿Ø¼þÖ®¼ä½øÐн»»¥£»ºÎʱִÐÐÖØÒªµÄ´¦ÀíÂß¼£»ÔÚ¸÷¸ö½×¶Î£¬¿Ø¼þ¿ÉʹÓÃÄÄЩÐÅÏ¢¡¢±£³ÖÄÄЩÊý¾Ý¡¢ ......
·µ»ØÉÏÒ»Ò³µÄÕâ¸ö¶«¶«ÔÚÎÒÃÇ×öÏîÄ¿µÄʱºòÒ»°ãÊÇÓÃÓÚÌîдÍê±íµ¥ºóÈ·ÈϵÄʱºò£¬ÓжÔÔÀ´ÊäÈëµÄÊý¾Ý½øÐÐÐ޸ĻòÕ߸üÐÂʱÓõ쬻òÕßÊÇÒòÎªÍøÕ¾ÎªÁË·½±ãä¯ÀÀÕß¶øÓÐÐÄÌí¼ÓµÄÒ»¸ö¶«¶«£¬Ò»°ãÕâÖÖ¹¦ÄܵÄʵÏÖÔÚASP.NETÖж¼ÊÇÓÃÒ»¸öButton¿Ø¼þÀ´ÊµÏֵģ¬ÊµÏֵķ½·¨Óкܶ࣬½ñÌìÇ¡ºÃÔÚ×öÏîĿʱÅöµ½ÒªÓÃÕâ¸ö¶«¶«£¬ÎҾͰÑÄÜʵÏÖ" ·µ» ......
ÓÉÓÚ asp.net ajax ·â×°Á˺ܶàºÜºÃµÄ·½·¨£¬ËùÒÔʹÓÃÕâ¸ö¿ò¼Üµ÷ÓÃwebwervice±äµÄ·Ç³£¼òµ¥¡£
µÚÒ»²½
webservice ÀàµÄ·½·¨ÐèÒªÓÐscriptServiceµÄ attribute.
namespace ServiceTest
{
/// <summary>
///WebService µÄժҪ˵Ã÷
/// </summary>
[WebService(Namespace = "http://tem ......