当前位置:编程学习 > C#/ASP.NET >>

vs2005中用ScriptManger 速度特慢,并且客户端调用时出现错误,无法实现局部刷新

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                                <ContentTemplate>      
                                                    <asp:TextBox ID="TextBox1" runat="server" CssClass="text" Width="50px" OnTextChanged="TextBox1_TextChanged" AutoPostBack="True"></asp:TextBox>
                                                    <asp:DropDownList ID="ddlregister"  Height="25px" runat="server"></asp:DropDownList>
                                                </ContentTemplate>
                                            </asp:UpdatePanel>
代码就这样,有哪位同仁帮忙看看! --------------------编程问答-------------------- 我现在ajax做了个一段程序,总提示有脚本错误:帮忙看看,代码如下:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script >
       function cityResult() 
            { 
                //var city=document.getElementById("DropDownList1");
                var = va = document.getElementById("<%=TextBox2.ClientID%>").innerText;
                AjaxMethod.GetCityList(va,get_city_Result_CallBack);
            }
            
            function get_city_Result_CallBack(response)
            {
                if (response.value != null)
                {                    
                    //debugger;
                    document.all("ddlNativePlace").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].dmhy;
                      var id=ds.Tables[0].Rows[i].dm;
                      document.all("ddlNativePlace").options.add(new Option(name,id));
                    }
                    }
                }                
                return
            }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        
    <div>
       <asp:TextBox ID="TextBox2" CssClass="text" Width="50px" runat="server" ></asp:TextBox><asp:DropDownList ID="ddlNativePlace"  Height="25px" runat="server"></asp:DropDownList>
                                               
    </div>
    </form>
</body>
</html>

cs文件:

 Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod));
        if (!Page.IsPostBack)
        {
            DataSet ds51 = new DataSet();
            ds51 = m_DataManager.GetCode("AB");
            ddlNativePlace.DataSource = AjaxMethod.GetCityList("");
            ddlNativePlace.DataTextField = "dmhy";
            ddlNativePlace.DataValueField = "dm";
            ddlNativePlace.DataBind();
            ddlNativePlace.Items.Insert(0, "请选择");
            this.TextBox2.Attributes.Add("onchange", "cityResult();");
        }

public class AjaxMethod
{
    [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
    public DataSet GetCityList(string provinceid)
    {
        string sql = "";
        if (provinceid == "")
        {
            sql = "select * from Code where dlm='AB'";
        }
        else
        {
         sql = "select * from Code where dlm='AB' and dm like'" + provinceid + "%";
        }        return GetDataSet(sql);
    }
    public static DataSet GetDataSet(string sql)
    {
        string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnStr1"];
        SqlDataAdapter sda = new SqlDataAdapter(sql, ConnectionString);
        DataSet ds = new DataSet();
        sda.Fill(ds);
        return ds;
    }


}
--------------------编程问答-------------------- 肯定是死循环,你调试下看看 --------------------编程问答-------------------- 调试了,不是死循环
在文本框输入信息后,没有反应,提示有脚本错误,缺少对象
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,