Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 349165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:25:58+00:00 2026-05-12T11:25:58+00:00

I have a WebPage on which I have to detect and prevent usage of

  • 0

I have a WebPage on which I have to detect and prevent usage of Browser Refresh Button. (Now Please, dont suggest me Response.Redirect, I wont be able to use it in this scenario).

On looking at this page http://aspalliance.com/687_Preventing_Duplicate_Record_Insertion_on_Page_Refresh.4 I found the way. I’m planning to put this idea in a Control and place the control on every page.

Now that my page contains so many buttons and other controls. My concern is, If it is a refresh post… I dont want any events to get fired…

It will be tedious to go and check whether it is a refresh post in the beginning of every event as my entire application is almost built.

Any ideas that would help me.

  • Raja

Including the below text for sake of more clarity :

Hi All, I hope a little misunderstanding… I dont want to stop user pressing the Refresh button… But all I want is to adjust my application’s response accordingly… Imagine a scenario, when user clicks BUTTON-A a popup window opens with another page. Now when the user comes back and clicks refresh button in the main window, the click event of BUTTON-A is fired again and popup window is opened again… In such scenario, I want to refresh the page as such, without opening the popup window. so, I need to stop ASP.NET from firing the click event of BUTTON-A (or any other similar buttons)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:25:59+00:00Added an answer on May 12, 2026 at 11:25 am

    This is at least a starting point on how you can do it. I’m not sure all logic is 100%, but it is something to begin with…

    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (Control control in Controls)
        {
            DisableEvent(control);
        }
    }
    protected void Page_PreRender(object sender, EventArgs e)
    {
        foreach (Control control in Controls)
        {
            UpdateViewstate(control);
        }
    }
    private void DisableEvent(Control current)
    {
        foreach (Control control in current.Controls)
        {
            if (control.GetType() == typeof(Button))
            {
                if (IsPostBack)
                {
                    if (Session["update" + control.ID].ToString() != ViewState["update" + control.ID].ToString())
                    {
                        RemoveClickEvent((Button)control);
                    }
                    else
                    {
                        ((Button)control).Click += new EventHandler(Button_Disable);
                    }
                }
                else
                {
                    Session["update" + control.ID] = Server.UrlEncode(System.DateTime.Now.ToString());
                }
            }
            DisableEvent(control);
        }
    }
    private void UpdateViewstate(Control current)
    {
        foreach (Control control in current.Controls)
        {
            if (control.GetType() == typeof(Button))
            {
                ViewState["update" + control.ID] = Session["update" + control.ID];
            }
            UpdateViewstate(control);
        }
    }
    
    void RemoveClickEvent(Button b) {
        System.Reflection.FieldInfo f1 = typeof(Button).GetField("EventClick", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); 
        object obj = f1.GetValue(b);
        System.Reflection.PropertyInfo pi = typeof(Button).GetProperty("Events", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        System.ComponentModel.EventHandlerList list = (System.ComponentModel.EventHandlerList)pi.GetValue(b, null); 
        list.RemoveHandler(obj, list[obj]); 
    }
    
    protected void Button_Disable(object sender, EventArgs e)
    {
        Button b = (Button)sender;
        Session["update" + b.ID] = Server.UrlEncode(System.DateTime.Now.ToString());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main window (#1) on my webpage from which I open a
We have an advanced webpage (ASP.NET, C#), and a application which needs to be
I have a txt file which actually is a html source of some webpage.
I have a webpage to which any amount of URL varibales could be set..
I have an image on a webpage which is being dynamically generated by a
I have a webpage which has 10 separate text input spaces. I need to
I have a webpage in which I let user to enter the contents, even
The Scenario: I have an ASP.Net webpage which I intend to use for letting
My colleagues have create a website and there is a webpage which contains a
Here's the scenario: I have an asp.net webpage which displays dynamic data in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.