supegong  

1.将ajax.dll下载并拷入文件夹,加成引用.

2.在web.config中加入

<httpHandlers>
      <!-- Register the ajax handler -->
      <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
    </httpHandlers>

 

3.新建1个页面,取名sample.aspx后台加入

<1>private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   Ajax.Utility.RegisterTypeForAjax(typeof(sample));
  }

<2>写1个方法

[Ajax.AjaxMethod()]

  public string test()
  {
   return " my test ajax";
  }

4.前台建两个方法:

function goTest()

{

  sample.test(getTest)

}

function getTest(res)

{

  alert(res.value);

5.建1个按钮,调用goTest()就行了.

posted on 2009-12-25 16:38  supegong  阅读(111)  评论(0)    收藏  举报