本人在編寫一個網頁的時候遇到一個错误 :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;
}
[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;
}
http://blog.163.com/renhappy20066/blog/static/112080786200952711165381/
顯示這段代碼有誤:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="MyRegister.Register" %>
(3)在Page_Load中药写入一行代码(4)就是每隔方法的上面要写[AjaxPro.AjaxMethod] ,具体的楼主可以上网看看
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>
</httpHandlers>在你要去访问AjaxMethod的类里注册Ajax.Utility.RegisterTypeForAjax(typeof(你写了AjaxMethod方法的类名));
那麼Page_Load中這樣寫對嗎?
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax
(typeof(WebForm1));
}