怎样防止用户刷新页面导致重新提交一次页面? 成功以后,不要刷新页面,而是重新载入页面.比如不使用:location.reload();而使用:location.href.location="本页面"; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 顺便说一句,我是用多个服务器控件Panel来显示挂号的每一个步骤的 <script language="Javascript"> function document.onkeydown() { if ((event.keyCode==8) || //屏蔽退格删除键 (event.keyCode==116)|| //屏蔽 F5 刷新键 (event.ctrlKey && event.keyCode==82)){ //Ctrl + R event.keyCode=0; event.returnValue=false; } if (window.event.srcElement.tagName == "A" && window.event.shiftKey) window.event.returnValue = false; //屏蔽 shift 加鼠标左键新开一网页 if ((window.event.altKey)&&(window.event.keyCode==115)) //屏蔽Alt+F4 { window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px"); return false; } } </script> 用viewstate做个标记不就可以了. 挂号成功转到另一个页面显示挂号生成的发票号、排队号和用户注意事项Response.Redirect(“成功页面.aspx”) 将点击提交按钮时的事件处理程序里加上: if(Request.Header["Accept"]!="*/*") { 点击提交按钮后的处理程序 } 你可以考虑下载我的控件试试.http://expert.csdn.net/Expert/topic/2561/2561040.xml?temp=.9271814主要是这样的方案.在显示Alert后,立刻回发一次就可以了。.代码举例public YourClass{ protected Button Button1; protected ControlHelper helper;//这个是直接从ToolBox中拖进去. public void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { helper=new ControlHelper(); Button1.Click+=new EventHandler(Button1_Click); } private void Button1_Click(object sender,EventArgs e) { helper.Alert("Message","Title",true);//显示Alert后立刻回发 }} void Page_Load(...){if( Page.IsPostback){ //save loggin information here ViewState["firstime"] = true;}else{ bool bFirstTime = ViewState["firstime"] == null?false:(bool)ViewState["firstime"]; if ( bFirstTime == true) { return; }else{//your business process }}} 刚才没有仔细看,有几种解决方法在cs代码做一个EnablePopup属性或者使用隐含控件<input type = hidden...>作为标志味或者使用ViewState 我认为使用标志比较好点,在JSP里记得有中在REQUEST 流里处理的方法,不知在ASP。NET REQUEST对象里是否也能类似处理 使用标志和viewstate应该都不行,因为当用户刷新或退到前一页后,标志和viewstate也会跟着变回原来的值,等于白用 "我现在做一个医院的患者网上挂号的功能,当患者挂号成功后,出现提示操作成功页面,如果刷新这一页面,挂号操作又会重新执行一次,从而多出许多没用的挂号记录。或者患者回退到上一页的挂号页面,再次点击挂号按钮,也会重新挂号。"我觉得你可以在挂号成功的页面PageLoad的时候对某个Session进行判断,如果不存在就赋值弹窗口,反之不弹,然后你在前一个页面中的pageload对Session清空,这样不知道是否符合你的想法 求Discuz .net版本中的短消息系统。 c#,js,css,bs,什么s高手都来帮帮忙哈 关于js的2级联动问题!!!!!!!!!!!!!! ???????数据库问题,在建立与服务器的连接时出错 要不要手动编译成dll呢??? 在datalist绑定数据显示成10行 的table,记录只有5个,怎么显示5行的空白行 “无法在Web服务器上启动调试,不支持此接口”这是什么意思? 小问题。帮个忙 MSDN的地址栏文件是.mspx,这是什幺格式? VS 2010 读取 Excel 2007 报错了 未授权ASP.Net进程访问所请求的资源......? 用户控件能不能接受参数?
function document.onkeydown()
{
if ((event.keyCode==8) || //屏蔽退格删除键
(event.keyCode==116)|| //屏蔽 F5 刷新键
(event.ctrlKey && event.keyCode==82)){ //Ctrl + R
event.keyCode=0;
event.returnValue=false;
}
if (window.event.srcElement.tagName == "A" && window.event.shiftKey)
window.event.returnValue = false; //屏蔽 shift 加鼠标左键新开一网页
if ((window.event.altKey)&&(window.event.keyCode==115)) //屏蔽Alt+F4
{
window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
return false;
}
}
</script>
Response.Redirect(“成功页面.aspx”)
if(Request.Header["Accept"]!="*/*")
{
点击提交按钮后的处理程序
}
在显示Alert后,立刻回发一次就可以了。.代码举例public YourClass
{
protected Button Button1;
protected ControlHelper helper;//这个是直接从ToolBox中拖进去. public void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
} private void InitializeComponent()
{
helper=new ControlHelper();
Button1.Click+=new EventHandler(Button1_Click);
} private void Button1_Click(object sender,EventArgs e)
{
helper.Alert("Message","Title",true);//显示Alert后立刻回发
}
}
{
if( Page.IsPostback)
{
//save loggin information here
ViewState["firstime"] = true;
}
else
{
bool bFirstTime = ViewState["firstime"] == null?false:(bool)ViewState["firstime"];
if ( bFirstTime == true)
{
return;
}
else
{
//your business process
}}
}
有几种解决方法在cs代码做一个EnablePopup属性
或者使用隐含控件
<input type = hidden...>作为标志味
或者使用ViewState
不知在ASP。NET REQUEST对象里是否也能类似处理