自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

短時間內(nèi)教會你VS2003代碼的使用與技巧

開發(fā) 后端
這里介紹VS2003代碼的使用與技巧,現(xiàn)在的項目準備用ajax,用ajax.net實現(xiàn),而不是atlas,所以先看下ajax.net,Ajax.Net現(xiàn)在的最新版本是AjaxPro5.11.4.2。

VS2003還是比較常用的,于是我研究了一下VS2003代碼,在這里拿出來和大家分享一下,希望對大家有用。這里介紹的有可能會有錯誤,希望大家對錯誤的VS2003代碼給予改正。

首先我們新建個項目,名字是AjaxPro,我用的是VS2003beta2版本。#t#

右擊站點名字點add reference添加對我們剛剛下載來的那個叫AjaxPro.2.dll的引用,如果你用的是VS2003代碼,則添加對AjaxPro.dll的引用,然后我們在添加個web.config文件(很郁悶的是vs2005不再自動添加web.config文件拉),修改web.config如下:type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/> 意思是所有的ajaxpro/*.ashx請求都由Ajax.PageHandlerFactory處理,而不是由默認的System.Web.UI.PageHandlerFactory處理程序工廠來處理。

我們現(xiàn)在給Default.aspx.cs文件添加個名字空間namespace MyDemo,這里更加郁悶的是為什么vs2005beta2怎么不給你自動添加名字空間啊?和2003怎么完全不同呢?

現(xiàn)在我們寫個AjaxMethod服務(wù)器端方法,他和普通的服務(wù)器方法***不同的地方就是他必須要在方法的上面添加個[AjaxPro.AjaxMethod],VS2003代碼如下:

  1. <%@ Page Language="C#"   
  2. AutoEventWireup="true"CodeFile="Default.aspx.cs"   
  3. Inherits="MyDemo._Default" %> 
  4. //W3C//DTD XHTML 1.1//EN"   
  5. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
  6. <html xmlns="http://www.w3.org/1999/xhtml" > 
  7. <head runat="server"><title>Untitled Page  
  8. title>head><body><form id="form1" 
  9. runat="server"><div><input id="Button1" 
  10. type="button" value="獲得服務(wù)器時間"   
  11. onclick="getServerTime();" /><input   
  12. id="Text1" type="text" /><input   
  13. id="Text2" type="text" /><input 
  14. id="Button2" type="button"   
  15. value="得到兩個文本框的和"   
  16. onclick="add(document.getElementById('Text1').  
  17. value,document.getElementById('Text2').value)"   
  18. />div>form><script   
  19. type="text/javascript"> 
  20. function getServerTime()  
  21. {  
  22. //MyDemo._Default.GetServerTime()  
  23. 得到從服務(wù)器傳來的數(shù)據(jù)是object,  
  24. 要寫.valuealert  
  25. (MyDemo._Default.GetServerTime().value);  
  26. }  
  27. function add(a,b)  
  28. {  
  29. //把文本框的值轉(zhuǎn)換成intvar   
  30. a1 = parseInt(a);var b1 = parseInt(b);  
  31. //第1、2參數(shù)為服務(wù)器方法所需要的參數(shù),  
  32. 后面一個是如果服務(wù)器返回數(shù)據(jù)  
  33. //客戶端要處理這些數(shù)據(jù)的js函數(shù)名,  
  34. 他有個參數(shù)就是從服務(wù)器傳來的數(shù)據(jù)  
  35. MyDemo._Default.AddTwo(a1,b1,getAdd);  
  36. }  
  37. function getAdd(rel)  
  38. {  
  39. //要加上.valuealert(rel.value);  
  40. }  
  41. script>body>html> 
  42. 后臺Default.aspx.cs代碼:  
  43. using System;using System.Data;  
  44. using System.Configuration;  
  45. using System.Web;  
  46. using System.Web.Security;using   
  47. System.Web.UI;  
  48. using System.Web.UI.WebControls;  
  49. using System.Web.UI.WebControls.WebParts;  
  50. using System.Web.UI.HtmlControls;  
  51. namespace MyDemo  
  52. {  
  53. public partial class _Default :   
  54. System.Web.UI.Page{protected void   
  55. Page_Load(object sender, EventArgs e){AjaxPro.Utility.RegisterTypeForAjax  
  56. (typeof(_Default));  
  57. }  
  58. [AjaxPro.AjaxMethod]public   
  59. DateTime GetServerTime()  
  60. {return DateTime.Now;  
  61. }[AjaxPro.AjaxMethod]public int AddTwo  
  62. (int firstInt, int secondInt)  
  63. {  
  64. return firstInt + secondInt;  
  65. }  
  66. }  
  67. }   
  68. }

以上就是我總結(jié)的關(guān)于VS2003代碼的有關(guān)內(nèi)容。

責任編輯:chenqingxiang 來源: NET130
相關(guān)推薦

2009-11-25 15:31:40

VS2003 SDK

2010-03-03 17:19:48

Android

2009-12-15 13:39:43

2010-02-05 14:40:14

Android開源系統(tǒng)

2010-02-24 13:56:27

Python編程語言

2010-01-19 18:18:21

C++語言

2010-03-17 13:07:47

交換機故障

2015-01-08 14:04:49

電信CDMA

2010-03-19 10:46:34

交換技術(shù)

2010-03-16 10:32:23

配置交換機

2009-11-25 09:26:39

VS2003代碼

2009-11-27 10:35:04

VS2003部署項目

2025-04-28 02:22:00

2009-11-30 17:00:05

VS2003窗口

2020-04-03 08:40:38

微軟谷歌無代碼

2009-12-01 09:51:40

VS2003數(shù)據(jù)庫

2009-11-26 09:28:56

VS2003打包

2013-01-13 10:01:18

2022-03-17 14:36:20

后門網(wǎng)絡(luò)安全

2009-12-01 16:32:20

VS2003安裝步驟
點贊
收藏

51CTO技術(shù)棧公眾號