if (!Page.IsPostBack)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(Index));
        }[AjaxPro.AjaxMethod]
    public int getClose()
    {
        int i = 0;
        try
        {
            i = bll.getClose(loginusername);
        }
        catch (Exception ess)
        {            throw new Exception(ess.Message);
        }
        return 1;    }这个是cs 申明的ajax function check()
{
showMsg();
count++;   
Index.getClose( "1",setReturn);
setTimeout("check()",3000);

}       
在前台 调用Index 的时候 说Index 没有定义 是怎么回事?

解决方案 »

  1.   

    AjaxPro.AjaxNamespace("");
    有没有申明命名空间
      

  2.   

    你WebConfig里的配置了没有?
    要在<system.web>下加入
                    <httpHandlers>
    <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
    </httpHandlers>
      

  3.   

    public  class AjaxMethod
    {
      public int getClose() 
        { 
    }
    }
    Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod));AjaxMethod.getClose();
    getClose() 是否在index类里
      

  4.   

    <httpHandlers>
             <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
    </httpHandlers>
      

  5.   

    这么明显的问题
    你传两个参数Index.getClose( "1",setReturn); 
    但cs文件却没有参数public int getClose() ,它怎么能调用!
      

  6.   

    呵呵这个到没发现
    public int getClose()
        {
            int i = 0;
            try
            {
                i = bll.getClose(loginusername);
            }
            catch (Exception ess)
            {            throw new Exception(ess.Message);
            }
            return 1;    } 
    改为
    public int getClose(int i)
        {
            try
            {
                i = bll.getClose(loginusername);
            }
            catch (Exception ess)
            {            throw new Exception(ess.Message);
            }
            return 1;    } 
      

  7.   

    另外你需要写setReturn()回调函数。
      

  8.   

    先不说能不能用的问题 index 直接来没有定义 
      

  9.   

    setReturn()这个我写好了的
    <httpHandlers> 
            <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/> 
    </httpHandlers> 这个在配置文件也有但是index 就是说没有定义
      

  10.   

    在index 页面 index.aspx.cs 里面
      

  11.   

    public int getClose() 这个方法得参数了Index.getClose( "1",setReturn); //这个方法getClose(接收了个"1")然后有个回调函数setReturn
    你在服务器端改为getClose(string i)
      

  12.   

    http://blog.csdn.net/an3gsonnzhy/archive/2009/02/16/3895203.aspx
      

  13.   

    那你去掉IsPostBack
    if (!Page.IsPostBack)
            {
                AjaxPro.Utility.RegisterTypeForAjax(typeof(Index));
            } 
    改为
     AjaxPro.Utility.RegisterTypeForAjax(typeof(Index));
    确保Index是你这个页面的类名!
      

  14.   

    这个要直接在啊page_load里面写
    不能在Ispostback里面写
      

  15.   

    那你本身这个页面是Index吗?
    像这样public partial class Index : System.Web.UI.Page
      

  16.   

    你的类有命名空间么?
     如果有 加上
    NamespaceName.Index.getClose( "1",setReturn); 
    你的aspx 页 的 form 有 runat="server" 么?
    没有的话 加上
      

  17.   

    你 的 Index  这个类 的命名空间 叫什么
      

  18.   

    好了问题弄出来了 原来是form 没有 runat="server" 
    谢谢各位啊 送分啊