本人在編寫一個網頁的時候遇到一個错误 :The type or namespace name 'AjaxPro' could not be found (are you missing a using directive or an assembly reference?) 無法調用到[AjaxPro.AjaxMethod],請問如何解決?
            [AjaxPro.AjaxMethod]
            public string GetReturnCode(string strName)
            {
                if (!IsUsernameExist(strName))
                {
                    return "1";
                }
                else
                {
                    return "0";
                }
            }
            private bool IsUsernameExist(string strUsername)
            {
                bool bRet = true;
                SqlServerDataBase db = new SqlServerDataBase();
                DataSet ds = db.Select("select * from ypCompanyInfo where CompanyName = '" + strUsername + "'", null);
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    bRet = false;
                }
                else
                {
                    bRet = true;
                }                return bRet;
            }

解决方案 »

  1.   

    手把手教你用AjaxPro,
    http://blog.163.com/renhappy20066/blog/static/112080786200952711165381/
      

  2.   

    添加了AjaxPro.dll之後出現另外一個問題:D:\My Documents\Visual Studio 2005\WebSites\WebSite3\Register.aspx: ASP.NET 运行时错误: Could not load file or assembly 'AjaxPro' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    顯示這段代碼有誤:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="MyRegister.Register" %>
      

  3.   

    关于如何是用AjaxPro网上有很详细的文章,还有我记得(1) 就是引用AjaxPro.dll(2)在web.config中写入一句话 <add verb="POST,GET" path="ajaxpro/*.ashx" type ="AjaxPro.AjaxHandlerFactory,AjaxPro"/>
    (3)在Page_Load中药写入一行代码(4)就是每隔方法的上面要写[AjaxPro.AjaxMethod] ,具体的楼主可以上网看看
      

  4.   

    添加AjaxPro.dll的引用~    在webconfig里配置   <httpHandlers>
    <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>
        </httpHandlers>在你要去访问AjaxMethod的类里注册Ajax.Utility.RegisterTypeForAjax(typeof(你写了AjaxMethod方法的类名));
      

  5.   

    我在 web.config已經添加了 <add verb="POST,GET" path="ajaxpro/*.ashx" type ="AjaxPro.AjaxHandlerFactory,AjaxPro"/> 
    那麼Page_Load中這樣寫對嗎?
       protected void Page_Load(object sender, EventArgs e)
        {
             AjaxPro.Utility.RegisterTypeForAjax
            (typeof(WebForm1));
        }