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

Duplicate: Should I pursue ASP.NET WebForms or ASP.NET MVC? We are developing an enterprise
Possible Duplicate: Link Button on the page and set it as default button, work
Possible Duplicate: ASP.NET “special” tags I hope this isn't too much of a newbie
Possible Duplicate: Biggest advantage to using ASP.Net MVC vs web forms maybe it feels
Possible Duplicate: Biggest advantage to using ASP.Net MVC vs web forms I'm soon gonna
Possible Duplicate: How serious is this new ASP.NET security vulnerability and how can I
Possible Duplicate: What’s your choice for your next ASP.NET project: WebForms or MVC? Can
Duplicate of 249087 I have a bunch of user generated addresses that may contain
I am creating a dynamic table control with ASP.NET/C# and the table is being
I have a page with a form where I'm trying to prevent duplicate submission,

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.