| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1214 人关注过本帖
标题:AjaxPro....实现不了无刷新联动。。代码如下
只看楼主 加入收藏
jinjinanni
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-6-19
结帖率:25%
收藏
 问题点数:0 回复次数:0 
AjaxPro....实现不了无刷新联动。。代码如下
cs代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
[AjaxPro.AjaxNamespace("chen")]
public partial class _Default : System.Web.UI.Page
{
    ODB lonk = new ODB();
    protected void Page_Load(object sender, EventArgs e)
    {
        AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
        lonk.DDlist("Country_ID", "Country_Name", "Country", ddlPro);
        this.ddlPro.Attributes["onchange"] = "ShowCity(this.options[selectedindex].vaule)";
    }
    [AjaxPro.AjaxMethod]
    public DataTable getCityList(int id)
    {
        Hashtable ht = new Hashtable();
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\DropDownList.mdb"));
        conn.Open();
        string strsql = "select * from State where Country_ID="+id+" ";
        OleDbCommand cmd = new OleDbCommand("",conn);
         = strsql;
        OleDbDataAdapter da = new OleDbDataAdapter();
        da.SelectCommand = cmd;
        DataTable dt = new DataTable();
        da.Fill(dt);
        return dt;

    }
}
 aspx代码:head runat="server">
    <title>无标题页</title>
    <script type="text/javascript">
    function ShowCity(id)
    {
    var result=chen.getCityList(id).value;
    var ddlcity=document.getElementById("ddlCity");
    ddlcity.length=0;
    for(var i=0;i<result.Rows.length;i++)
    {
     ddlcity.options.add(new Option(result.Rows[i].State,result.Rows[i].id))
    }
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <p>
        <asp:DropDownList ID="ddlPro" runat="server">
        </asp:DropDownList></p>
        <p><asp:DropDownList ID="ddlCity" runat="server">
        </asp:DropDownList></p>
    </div>
    </form>
</body>
</html>
搜索更多相关主题的帖子: AjaxPro 代码 
2009-08-06 14:22
快速回复:AjaxPro....实现不了无刷新联动。。代码如下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030267 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved