---
title: "Button click event handler fired on page refresh"  
description: "Button click event handler fired on page refresh"  
author: "Anonymous User"  
published: 2014-08-22  
updated: 2014-08-22  
canonical: https://www.mindstick.com/forum/2084/button-click-event-handler-fired-on-page-refresh  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Button click event handler fired on page refresh

I have an [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control), which seems to fire the [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) [event handler](https://www.mindstick.com/forum/1371/c-sharp-dot-net-event-handler-delegate-question) on a [page refresh](https://www.mindstick.com/forum/158700/how-can-implement-client-side-form-submission-and-prevent-page-refresh-using-jquery). Why does this happen and how could I [avoid](https://yourviews.mindstick.com/story/1518/tips-to-avoid-dengue-at-home) it?

## Replies

### Reply by Sumit Kesarwani

Hi Ankita, try this:\

```
protected void Page_Load(object sender, EventArgs e)    {        if(!IsPostBack)           
Session["update"] =Server.UrlEncode(System.DateTime.Now.ToString());    }    protected override void OnPreRender(EventArgs e)    {       
ViewState["update"] = Session["update"];    }    protected void btnProceed_Click(object sender, EventArgs e)    {                   if(Session["update"].ToString() ==ViewState["update"].ToString())           
DisplayInfo();    }    private void DisplayInfo()    {        // Do what ever thing you want to do       
Session["update"] =Server.UrlEncode(System.DateTime.Now.ToString());      }
```


---

Original Source: https://www.mindstick.com/forum/2084/button-click-event-handler-fired-on-page-refresh

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
