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 187867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:54:01+00:00 2026-05-11T15:54:01+00:00

Duplicate of Asp.Net Button Event on refresh fires again??? GUID? hello, ive a website

  • 0

Duplicate of Asp.Net Button Event on refresh fires again??? GUID?

hello, ive a website and when a user click a button and the page postback, if the user refresh the Page or hit F5 the button method is called again.

any one know some method to prevent page refresh with out redirect the page to the same page again ?

something like if (page.isRefresh) or something… or if exist any javascript solution is better.

this seen to works…. but when i refresh it does not postback but show the before value in the textbox

http://www.dotnetspider.com/resources/4040-IsPageRefresh-ASP-NET.aspx

private Boolean IsPageRefresh = false; protected void Page_Load(object sender, EventArgs e) {             if (!IsPostBack)     {         ViewState['postids'] = System.Guid.NewGuid().ToString();         Session['postid'] = ViewState['postids'].ToString();         TextBox1.Text = 'Hi';      }     else     {         if (ViewState['postids'].ToString() != Session['postid'].ToString())         {             IsPageRefresh = true;         }         Session['postid'] = System.Guid.NewGuid().ToString();         ViewState['postids'] = Session['postid'];     } } protected void Button1_Click(object sender, EventArgs e) {     if (!IsPageRefresh) // check that page is not refreshed by browser.     {         TextBox2.Text = TextBox1.Text + '@';      } } 
  • 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. 2026-05-11T15:54:02+00:00Added an answer on May 11, 2026 at 3:54 pm

    Thanks for comments and sorry for my mistake, I found this code in: http://www.codeproject.com/KB/aspnet/Detecting_Refresh.aspx And this time tested 😉

        private bool _refreshState;     private bool _isRefresh;      protected override void LoadViewState(object savedState)     {         object[] AllStates = (object[])savedState;         base.LoadViewState(AllStates[0]);         _refreshState = bool.Parse(AllStates[1].ToString());         _isRefresh = _refreshState == bool.Parse(Session['__ISREFRESH'].ToString());     }      protected override object SaveViewState()     {         Session['__ISREFRESH'] = _refreshState;         object[] AllStates = new object[2];         AllStates[0] = base.SaveViewState();         AllStates[1] = !(_refreshState);         return AllStates;     }      protected void btn_Click(object sender, EventArgs e)     {         if (!_isRefresh)             Response.Write(DateTime.Now.Millisecond.ToString());     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to: Back button support “Ajax” I have a ASP.NET MVC implementation
Possible Duplicate: Get URL of ASP.Net Page in code-behind I'm trying to hold current
Possible Duplicate: Text on an Image button in c# asp.net 3.5 I want a
Possible Duplicate: Multiple forms on ASP.NET page i have a doubt. can we place
Possible Duplicate: ASP.NET authentication login and logout with browser back button I want to
Possible Duplicate: ASP.Net: DropDownList's SelectedIndexChanged event not firing I created a new ASP.NET default
Possible Duplicate: ASP.NET postback with JavaScript I have a page without a form. But
Possible Duplicate: Asp.net how to correct the error I'm designing my web page using
Possible Duplicate: Asp.net MVC page is giving Mime type warnings for image files I
Duplicate Passing data to Master Page in ASP.NET MVC Should an ASP.NET masterpage get

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.