Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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
Posted
Updated 15-Feb-11 19:05pm
v2
Comments
Sandeep Mewara 16-Feb-11 1:20am    
Surely your previous event before 'Refresh' would be *that* button click.
Monjurul Habib 16-Feb-11 1:52am    
please share your code to identify your problem.

1 solution

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
C#
Response.Cache.SetCacheability(HttpCacheability.NoCache);
in Page_Load event.

3) Use javascript like

JavaScript
document.onkeydown = function() 
{
           if(event.keyCode==116)
           {
               event.keyCode=0;
               event.returnValue = false;
           }
}

document.oncontextmenu = function() {event.returnValue = false;}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900