问题是这样的,我和一个朋友一起做一个项目,昨天他把他做好剩下的那块交给我接着做,但他在项目中引用了一个Ajax.dll,并且在程序有Ajax.Utility.RegisterConverterForAjax(typeof(AjaxMethod)); 这样的程序.现在我拿过来的时候,让我重新引用一下Ajax.dll到项目中,我引用了,并且在web.config中照他的意思也配置了<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" /></httpHandlers> 但运行还是出错,说找不到AjaxMethod,我问他,他说在他机子上这样配置是好的.我现在不知道该怎么办了,只有寄希望与此.希望得到大家的指点.

解决方案 »

  1.   

    有脚本错误是嘛意思?我想可能是引用的问题,引用Ajax.dll的时候还需要做什么配置?
      

  2.   

    Ajax.Utility.RegisterConverterForAjax(typeof(这里换成当前页面的className));
      

  3.   

    把Ajax.dll引用到项目中后,然后再web.config也配置了httpHandlers>
    <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" /></httpHandlers>
    出现的错误是 找不到 AjaxMethod(缺少using 引用,或程序集引用) ,AjaxMethod这个是Ajax.dll中的一个类名,我不知道正确的引用Ajax.dll,然后在访问里面的类名? 这就是现在问题.
      

  4.   

    可能还有名称空间AjaxPro.
      

  5.   

    这是程序:
    public class addadmin : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Button Button1;
    protected System.Web.UI.WebControls.DropDownList DropDownList1;
    protected System.Web.UI.WebControls.DropDownList DropDownList2;
    protected System.Web.UI.WebControls.Label Label1;
    string S_id;
    private void Page_Load(object sender, System.EventArgs e)
    {
                // 在此处放置用户代码以初始化页面
    Ajax.Utility.RegisterConverterForAjax(typeof(AjaxMethod));//就是在这里的AjaxMethod会出错,改成addadmin还是会.
    if(!Page.IsPostBack)
    {   
    S_id=Request.QueryString["S_id"].ToString();
    this.Label1.Visible=false;
    this.DropDownList1.DataSource=AjaxMethod.GetPovinceList();//还有这个AjaxMethod也会出错 
    this.DropDownList1.DataTextField="module_name";
    this.DropDownList1.DataValueField="table_name";
    this.DropDownList1.DataBind(); this.DropDownList1.Attributes.Add("onclick","cityResult();");  
    }


    }
    //下面的可以不看了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    string SqlConn=System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
    SqlConnection Conn=new SqlConnection(SqlConn);
    Conn.Open();
              
                string tableName = Request.Form["DropDownList1"].ToString();
    //读取管理员表名称
    string SqlStr="select * from modules where table_name='"+tableName+"'";
    SqlCommand Comm=new SqlCommand(SqlStr,Conn);
    SqlDataReader read=Comm.ExecuteReader();
    read.Read();
    string adminName=read["admin_name"].ToString();
    read.Close();            //判断表里是否已有该用户
    string SqlStr1="select * from "+adminName+" where user_ID='"+Request.QueryString["S_id"].ToString()+"'";
    SqlCommand Comm1=new SqlCommand(SqlStr1,Conn);
    SqlDataReader read1=Comm1.ExecuteReader();
    if(read1.Read())
    {
    Response.Write("<script language=javascript>alert('该用户已经是该系统管理员,请在用户管理里修改其权限!');</script>");
                    read1.Close();
    }
    else
    {
    read1.Close();
    //将管理用户添加到相应模块的管理员表
    string SqlStr2="insert into "+adminName+"(user_ID,rulesID) values(@TuserID,@TrulesID)";
                    SqlCommand Comm2=new SqlCommand(SqlStr2,Conn); Comm2.Parameters.Add("@TuserID",SqlDbType.Int);
    Comm2.Parameters.Add("@TrulesID",SqlDbType.Int); Comm2.Parameters["@TuserID"].Value=Request.QueryString["S_id"].ToString();
    Comm2.Parameters["@TrulesID"].Value=Request.Form["DropDownList2"].ToString(); Comm2.ExecuteReader();
    this.Label1.Visible=true;
    Response.Redirect("addadmin.aspx?S_id="+Request.QueryString["S_id"].ToString()+"");

    }
    } }
      

  6.   

    慕白大哥 还在吗?上面是我的程序,在有AjaxMethod处总会出错,改成页面的类名addadmin好像也没用.
      

  7.   

    在你调用方法前面是不是要加[Ajax.Ajaxmethod]的啊
      

  8.   

    其实这是一个别人做好的一个Ajax无刷新联动组建,现在再引用的时候出错了.整个代码程序是这样的:
    前面的javascript是:
    <script language="javascript">
        function cityResult() 

    var city=document.getElementById("DropDownList1");
    AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
    }

    function get_city_Result_CallBack(response)
    {
    if (response.value != null)
    {
    //debugger;
    document.all("DropDownList2").length=0;    
         var ds = response.value;
    if(ds != null && typeof(ds) == "object" && ds.Tables != null)
    {
    for(var i=0; i<ds.Tables[0].Rows.length; i++)
         {
         var name=ds.Tables[0].Rows[i].rules;
           var id=ds.Tables[0].Rows[i].rulesID;
           document.all("DropDownList2").options.add(new Option(name,id));
         }
    }
    }
    return
    }
    function getData()
    {
    var province=document.getElementById("DropDownList1");
    var pindex = province.selectedIndex;
    var pValue = province.options[pindex].value;
    var pText  = province.options[pindex].text;

    var city=document.getElementById("DropDownList2");
    var cindex = city.selectedIndex;
    var cValue = city.options[cindex].value;
    var cText  = city.options[cindex].text;
    }
    </script>后台的程序是这样的:
    类名为:addadmin
    protected System.Web.UI.WebControls.Button Button1;
    protected System.Web.UI.WebControls.DropDownList DropDownList1;
    protected System.Web.UI.WebControls.DropDownList DropDownList2;
    protected System.Web.UI.WebControls.Label Label1;
    string S_id;
    //[AjaxPro.AjaxMethod]
    private void Page_Load(object sender, System.EventArgs e)
    {
                // 在此处放置用户代码以初始化页面
    Ajax.Utility.RegisterConverterForAjax(typeof(AjaxMethod));//这是就是出错的地方,改成类名addadmin也不行.
    if(!Page.IsPostBack)
    {   
    S_id=Request.QueryString["S_id"].ToString();
    this.Label1.Visible=false;
    this.DropDownList1.DataSource=AjaxMethod.GetPovinceList();//还有这里的AjaxMethod一样出错
    this.DropDownList1.DataTextField="module_name";
    this.DropDownList1.DataValueField="table_name";
    this.DropDownList1.DataBind(); this.DropDownList1.Attributes.Add("onclick","cityResult();");  
    }


    }
      

  9.   

    前台页面最上边加:
    <script type="text/javascript" src="/ajax/common.ashx"></script>
    <script type="text/javascript" src="/ajax/项目名字.类名,项目名.ashx"></script>
    类:
    /// <summary>
    /// 
    /// </summary>
    /// <param name="keyValue"></param>
    /// <param name="contentType"></param>
    /// <returns></returns>
    [Ajax.AjaxMethod()]
      

  10.   

    在最上面引用  using AjaxPro; 试试!你是不是缺少一个.cs文件呀?应该有一个类库的,是不是你朋友忘了给你传了?
      

  11.   

    应该没有吧 他该拿给我的都拿了,照楼上的做法还是不行,总是出现找不到 AjaxMethod(缺少using 引用,或程序集引用),我换成成我的类名addadmin还是不行.太急人啦
      

  12.   

    删掉Ajax.dll,重新引用,如果不行,重复多几次
      

  13.   

    楼主用的是AjaxPro吧?Ajax.Utility.RegisterConverterForAjax(typeof(AjaxMethod))这里应该注册包含你要调用的ajaxmethod的类名,在你的例子中应该是addadmin,所以应该写成这样:
    Ajax.Utility.RegisterConverterForAjax(typeof(addadmin));
      

  14.   

    恩 好 感谢版主,我刚才问那个朋友 他的一个AjaxMethod.cs类文件好象忘记拷给我了,我现在去拷,回来再试试.应该是Ajax.Utility.RegisterConverterForAjax(typeof(AjaxMethod)) 就可以了,他的类文件名为:AjaxMethod
      

  15.   

    的确需要AjaxMethod.cs,里面链接数据库返回你需要的dataset;
      

  16.   

    不好意思了vlysses(张家) 下次再给分,其实不用using AjaxPro;也可以