非常郁闷 由于表单比较长,执行了RadioButtonList的OnSelectedIndexChanged事件总是刷回到页头 有什么办法不刷新 或者 刷新后还回到原来的位置么?

解决方案 »

  1.   

    放在Ajax的UpdatePanel控件里
      

  2.   

    autopostback设成false,但这样你后台事件就触发不了了,如果你想回后台处理的,又不要页面不刷新的,请用AJAX
      

  3.   


    能给个例子么 本来没用过ajax
      

  4.   


    页面代码<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
                  <asp:ListItem Selected="True" Value="1">订 金</asp:ListItem>
                  <asp:ListItem Value="0">完 款</asp:ListItem>
                  <asp:ListItem Value="2">退 订</asp:ListItem>
    </asp:RadioButtonList>对应的.cs文件里的方法protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string temp = RadioButtonList1.SelectedValue.ToString();
            if (temp.Equals("1"))//订金
            {
                tb_wankuanDate.Visible = false;
                lb_wankuanDate.Text = tb_wankuanDate.Text;
                tb_tuidingDate.Visible = false;
                lb_tuidingDate.Text = tb_tuidingDate.Text;
            }
            else if (temp.Equals("0"))//完款
            {
                tb_wankuanDate.Visible = true;
                lb_wankuanDate.Text = "";
                tb_tuidingDate.Visible = false;
                lb_tuidingDate.Text = tb_tuidingDate.Text;
            }
            else if (temp.Equals("2"))//退订
            {
                tb_wankuanDate.Visible = false;
                lb_wankuanDate.Text = tb_wankuanDate.Text;
                tb_tuidingDate.Visible = true;
                lb_tuidingDate.Text = "";
            }
        }
    楼上各位说的UpdatePanel应该怎么加呢?
      

  5.   

    回到原來位置的腳本
    if (document.all)
    {
        window.attachEvent("onload",function(){LoadWinScrollCookie();})
        window.attachEvent("onunload",function(){SetWinScrollCookie();})
    }
    else
    {
        window.addEventListener("load",function(){LoadWinScrollCookie();},false);
        window.addEventListener("unload",function(){SetWinScrollCookie();},false);
    }function SetWinScrollCookie()
    {
        document.cookie="scrollTop="+document.body.scrollTop;
        document.cookie="scrollLeft="+document.body.scrollLeft;
    }function LoadWinScrollCookie()
    {
        var allcookies=document.cookie;
        if(allcookies!=null)
        {
            var pos=allcookies.indexOf("scrollTop=");
            if(pos!=-1)
            {
                var start=pos+10;
                var end=allcookies.indexOf(";",start);
                if(end==-1) end=allcookies.length;
                var value=allcookies.substring(start,end);
                value=unescape(value);
                document.body.scrollTop=value;
            }
            pos=allcookies.indexOf("scrollLeft=");
            if(pos!=-1)
            {
                var start=pos+11;
                var end=allcookies.indexOf(";",start);
                if(end==-1) end=allcookies.length;
                var value=allcookies.substring(start,end);
                value=unescape(value);
                document.body.scrollLeft=value;
            }
        }
    }
      

  6.   


    <asp:UpdatePanel ID="UpDatePanle1" runat="server">
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
                  <asp:ListItem Selected="True" Value="1">订 金</asp:ListItem>
                  <asp:ListItem Value="0">完 款</asp:ListItem>
                  <asp:ListItem Value="2">退 订</asp:ListItem>
    </asp:RadioButtonList>
    </asp:UpdatePanel>差不多就这个意思了
      

  7.   

    我遇到的情况是,把RadioButton放到UpdatePanel里,AutoPostBack设置为True,仍然会刷新页面,郁闷中,大家能不能  把既能执行 OnSelectedIndexChanged ,又能防止页面刷新 的方法?期待中