Link to home
Start Free TrialLog in
Avatar of gpinfotech
gpinfotechFlag for India

asked on

how to disable refresh button for browser in asp.net

Hi experts,

I want to block refresh button for browser .
i am using following javascript ,it works for me ,but it is disabling only F5. Please help

if (document.all){
document.onkeydown = function (){
var key_f5 = 116; // 116 = F5

if (key_f5==event.keyCode){
event.keyCode = 27;

return false;
}
}
}
 
Avatar of Pratima
Pratima
Flag of India image

refer
http://forums.asp.net/p/1279327/2455531.aspx 
private bool _refreshState;
 private bool _isRefresh;

 protected override void LoadViewState(object savedState)
 {
     object[] AllStates = savedState;
     base.LoadViewState(AllStates(0));
     _refreshState = bool.Parse(AllStates(1));
     _isRefresh = _refreshState == Session("__ISREFRESH");
 }

 protected override object SaveViewState()
 {
     Session("__ISREFRESH") = _refreshState;
     object[] AllStates = new object[3];
     AllStates(0) = base.SaveViewState;
     AllStates(1) = !(_refreshState);
     return AllStates;
 }

Open in new window

SOLUTION
Avatar of robasta
robasta
Flag of Zimbabwe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please write JS to block the key F5 in keypress or keydown event.
Also hide the REfresh button using javascript.
Avatar of gpinfotech

ASKER

Thanks alot
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.