自动按钮单击Asp.net页面刷新 [英] Auto Button Click in Asp.net On Page Refresh
本文介绍了自动按钮单击Asp.net页面刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在页面上有两个按钮,当我刷新页面时,其中一个按钮单击事件正在起作用...
这是什么原因
请帮助我
I have two buttons on a page,when i refresh the page,one of the button click event is working...
What is the reason for this
Please help me
推荐答案
原因是提交的数据存储在viewstate中,刷新页面会重新激发点击.
根据您的实际情况,有许多解决方案:
1)执行一个response.redirect到同一页面,它将删除缓存并加载新页面.
2)在Page_Load事件中使用
Reason is that the submitted data gets stored in viewstate and refreshing the page re-fires the click.
There are many possible solutions depending on what suits you:
1) Do a response.redirect to same page and it will remove cache and fresh page will load.
2) Use
Response.Cache.SetCacheability(HttpCacheability.NoCache);
.
3)使用javascript
in Page_Load event.
3) Use javascript like
document.onkeydown = function()
{
if(event.keyCode==116)
{
event.keyCode=0;
event.returnValue = false;
}
}
document.oncontextmenu = function() {event.returnValue = false;}
这篇关于自动按钮单击Asp.net页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文