RadioButtonList的OnSelectedIndexChanged事件能不能不刷新页面 非常郁闷 由于表单比较长,执行了RadioButtonList的OnSelectedIndexChanged事件总是刷回到页头 有什么办法不刷新 或者 刷新后还回到原来的位置么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 放在Ajax的UpdatePanel控件里 autopostback设成false,但这样你后台事件就触发不了了,如果你想回后台处理的,又不要页面不刷新的,请用AJAX 能给个例子么 本来没用过ajax 页面代码<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应该怎么加呢? 回到原來位置的腳本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; } }} <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>差不多就这个意思了 我遇到的情况是,把RadioButton放到UpdatePanel里,AutoPostBack设置为True,仍然会刷新页面,郁闷中,大家能不能 把既能执行 OnSelectedIndexChanged ,又能防止页面刷新 的方法?期待中 使用 GridView 自带的查找 更新 删除 方法 petshop4使用问题,求助 VS2005怎么连接access数据库?急 请教XtraReports xrRichText的问题 大家看看怎么做? document.createElement("div")后如何取他的属性啊 VBA EXCEL 如何判断字符窜是否英数字 e.Item.Attributes.Add()的用法? 可否通过网页启动服务器上的应用程序 我要用一个单选的控件,列很多选项,…… 用继承实现asp.net三层架构好不好? 请教dotnet学习路线与推荐书籍
能给个例子么 本来没用过ajax
页面代码<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应该怎么加呢?
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;
}
}
}
<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>差不多就这个意思了