RT

解决方案 »

  1.   

    唉,当初做这个用AjaxPro来做,做完之后发现BUG,怎么都搞不定
    一气之下就直接上AJAX.NET,updatepane,拖控件,拖控件,拖控件,拖控件,完事。
      

  2.   

    唉,当初做这个用javascript来做,
    后来就AJAX的updatepane,拖控件,拖控件,拖控件,拖控件,完事。
      

  3.   

    简单实例
    http://www.code-123.com/html/20087151126431451966.html
      

  4.   

    http://www.code-123.com/html/20087151126431451966.html
      

  5.   

    发个ListBox的 自己看 不过用了JQuery<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>ListBox Ajax</title>
        <script src="js/jquery.js" type="text/javascript"></script>
        <script language="javascript" type="text/javascript">
            $(document).ready(function(){
                $('#lb_Father').click(function(){
                    $.ajax({type:'get',url:'SonType.ashx?command=getson',success:function(html){
                        $('#lb_Son').empty().append(html);
                    }});
                });
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ListBox ID="lb_Father" runat="server" Width="150px">
                <asp:ListItem Text="我是一" Value="1"></asp:ListItem>
                <asp:ListItem Text="我是二" Value="2"></asp:ListItem>
            </asp:ListBox>
            <asp:ListBox ID="lb_Son" runat="server" Width="150px"></asp:ListBox>
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        </div>
        </form>
    </body>
    </html>SonType.ashxpublic class SonType : IHttpHandler {
        
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/plain";        if (context.Request.QueryString["command"] != null)
            {
                string command = context.Request.QueryString["command"].ToString();
                if (command == "getson")
                {
                    string items = "";
                    string item = "";
                    for (int i = 0; i < 10; i++)
                    {
                        item = "<option value=" + (i + 1) + ">item" + (i + 1) + "</option>";
                        items += item;
                    }
                    context.Response.Write(items);
                }
            }
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }}
      

  6.   


    <script language="javascript" type="text/javascript">
            $(document).ready(function(){
                $('#lb_Father').click(function(){
                    $.ajax({type:'get',url:'SonType.ashx?command=getson',success:function(html){
                        $('#lb_Son').empty().append(html);
                    }});
                });
            });
        </script>
    还是说说
    $(document).ready();当DOM加载完成后,执行其中的函数
    $('#lb_Father').click(fn) 获取id为 lb_Father的DOM元素
    .click(fn) 单击事件
    $等于Jquery对象
    $.ajax() 这是jquery的AJAX实现,简化了AJAX的操作,type请求方式,url请求地址,success请求成功后回调的方法
    .empty()清空元素的子元素.
    .append()在此元素追加内容
    最后function(html)中的html是服务器响应发回的数据
      

  7.   

    http://blog.csdn.net/wxg22526451/archive/2008/04/24/2323244.aspx
      

  8.   

    jcrjia
    用了你的方法,弹出缺少对象!
    $(document).ready(function(){
                $('#lb_Father').click(function(){
                    $.ajax({type:'get',url:'SonType.ashx?command=getson',success:function(html){
                        $('#lb_Son').empty().append(html);
                    }});
                });
            });
      

  9.   

    搞定了,这个JS<script src="js/jquery.js" type="text/javascript"></script>去网上下一个就OK了!
    加上这个就没有错误了!剩下的就是SonType.ashx?command=getson改变getson值,根据这个在ashx里加载需要的东西,这个很简单了!
      

  10.   

    jcrjia的方法不错,测试无误!