Click here to Skip to main content
15,031,361 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends....

I have a problem with developing a project, Please try to help me...
That problem is how to disable the refresh key(F5 & Enter key) after page loaded?
Posted
Comments
fjdiewornncalwe 2-Mar-12 9:46am
   
Don't try to change default browser behavior. The proper solution is to do something like what Bojjaiah has suggested below. Handle the user's refresh click in your code properly. Trying to shortcut proper process by disabling default browser behavior is not advisable.

1 solution

try this,

<div>
       <asp:label id="Label1" runat="server" text="Label" xmlns:asp="#unknown"></asp:label><br />
       <br />
       <asp:button id="Button1" runat="server" onclick="Button1_Click" text="Button" xmlns:asp="#unknown" /></div>


protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
           Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString());
       }


   }
   protected void Button1_Click(object sender, EventArgs e)
   {
       if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString())
       {
           Label1.Text = "Hello";
           Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString());
           string str = "your code will save here or call save() method here";

       }
       else
       {
           Label1.Text = "Page Refreshed";
                   }

   }
   protected void Page_PreRender(object sender, EventArgs e)
   {
       ViewState["CheckRefresh"] = Session["CheckRefresh"];
   }


this code not disable F5 & EnterKey button

it's handle to save ur code safly when browser refresh or F5.
   
v3
Comments
sureshveera 4-Mar-12 4:08am
   
Thanks
Bojjaiah 19-Mar-12 9:21am
   
Welcome :)

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