Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi guys, I want Ascii value for Refresh button. I think Refresh button and F5 function are same . But problem here is , one Linkbutton in my page , when click on the Linkbutton open the new window. Here is when click on the refresh button or F5 , it will open the same window again.

I wrote the code for stoping F5 :

C#
document.attachEvent("onkeydown", my_onkeydown_handler);
window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);


function my_onkeydown_handler() {
 switch (event.keyCode) {

      case 116: // 'F5'
          event.returnValue = false;
          event.keyCode = 0;
         // window.status = "We have disabled F5";
          window.event.cancelBubble = true;
          break;
      }
  }


F5 ascii is 116,
is there solution for stoping refresh button of browser .

could you please any one help me.....
Posted
Updated 24-Jul-12 22:41pm
v3
Comments
Sergey Alexandrovich Kryukov 25-Jul-12 2:35am    
Who told you there should be such weird thing as the ASCII value? Besides, each browser could do it its own way...
--SA
CH Guravaiah 25-Jul-12 2:40am    
thanks yar, but how to solve my problem , Is there any solution for solving my problem
Sergey Alexandrovich Kryukov 25-Jul-12 2:40am    
"F5 ascii is 116". To start with, please try not to lie.
--SA
CH Guravaiah 25-Jul-12 2:41am    
already done for f5 and the code is already pasted. i want for refresh button.
Sergey Alexandrovich Kryukov 27-Jul-12 17:14pm    
Key code has nothing to do with ASCII. I told you that you should not lie, but instead you lie again.
--SA

No for that you have to open pop-up window using window.open() function...In this function you can specify many option so not display toolbar of browser so its solve your problem..& disabled F5 key using your javascript code...So by both these way you restrict end user to refresh your page...For more information of windwo.open() check given link
http://www.w3schools.com/jsref/met_win_open.asp[^]
 
Share this answer
 
Comments
CH Guravaiah 30-Jul-12 5:29am    
hi,I was mentioned in the below code . But it does not working.

Protected Sub lbnDetails_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Try lblRecordsperPage.Visible = True

ddlRecordsperPage.Visible = True

'When Clicking on the View LinkButton. It will Redirect to the Lease Details Page.

Dim lbnDetails As LinkButton = CType(sender, LinkButton)

'*** Creating Object for GridViewRow

Dim gvRow As GridViewRow = CType(lbnDetails.NamingContainer, GridViewRow)

'*** Getting Values of Fields Using DataKeyNames

objLeaseSearch.LeaseID = gvwLeaseReviewSummary.DataKeys(gvRow.RowIndex).Values(0)

objLeaseSearch.LeaseVersionNumber = gvwLeaseReviewSummary.DataKeys(gvRow.RowIndex).Values(1)

ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "Window", "ViewInternalID();", True)

Catch ex As Exception

SetUserMessage(ex.Message, MessageType.ErrorMessage)

ErrorSignal.FromCurrentContext.Raise(ex) End Try End Sub

function ViewInternalID() {

window.open("LeaseDetail.aspx",'_blank','width=800px,height=500px,scrollbars=yes, status=no, resizable=yes,titlebar=yes,menubar=yes');

}
The "refresh button" does not have an ASCII value, or a keycode - it is not activated by the keyboard, it is a mouse click.

You cannot disable F5 reliably in all browsers, and AFAIK it can't even be disabled reliably in any browser! The refresh button you have no access to at all in all browsers.
 
Share this answer
 
Comments
CH Guravaiah 25-Jul-12 2:11am    
how to resolve my problem. Is there any other solution.
Sergey Alexandrovich Kryukov 25-Jul-12 2:39am    
Please, stop it. This is not your problem. You problem that you don't tell us your real goal, or worse, don't know it yourself (which is very likely). The whole idea is totally wrong. You can get any help only if you explain why are you trying to do such weird thing.
--SA
Sergey Alexandrovich Kryukov 25-Jul-12 2:38am    
I would not pay much attention for this (correct) answer if not the OP's comment and someone's idiotic vote of 3. I voted 5 (not to compensate, but because this is a correct answer).
--SA
CH Guravaiah 25-Jul-12 3:08am    
wow, you want votes , thats way your are reply. every one not good in english. based on my knowledge i can send the question.
OriginalGriff 25-Jul-12 3:15am    
Pardon? That doesn't make a lot of sense in English?
Would you like to try again?

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