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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:49:38+00:00 2026-05-26T06:49:38+00:00

If I have this asp.net button: <asp:Button ID=Button_Save Width=150px OnClick=Button_Save_Click runat=server Text=Save /> In

  • 0

If I have this asp.net button:

<asp:Button ID="Button_Save" Width="150px" OnClick="Button_Save_Click" runat="server" Text="Save" />

In order to prevent the user to press the button twice to insert two data records, I added this in the code behind:

Button_Save.Attributes.Add("onclick", "this.disabled='true';" + ClientScript.GetPostBackEventReference(Button_Save_Data, null) + ";");

It works fine with IE and Chrome. However, in Firefox, every time the user presses the button once, I got two data records inserted.

After some time googling, I modified the button this way by adding: UseSubmitBehavior="false":

<asp:Button ID="Button_Save" Width="150px" UseSubmitBehavior="false" OnClick="Button_Save_Click" runat="server" Text="Save" />

Then it also works with Firefox, only one data record inserted. But then I will have to add that setting for every button on my web application. It requires a lot of work.

However, I think this is really a big problem if that is the case always with asp.net app running on Firefox. Or did I implement something wrong?

Thanks in advance.

  • 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-26T06:49:39+00:00Added an answer on May 26, 2026 at 6:49 am

    You would be better off adding checks to your SAVE code to prevent duplicate POSTs. I’ve used code like yours and still had duplicate records because someone hit the Refresh button at the wrong time.

    EDIT:
    Here is the code I use. Key is to match a value on the server with a value coming back in the postback.

    In Page_Load:

    If Not IsPostBack Then
        Session("rcdupdate") = Server.UrlEncode(System.DateTime.Now.ToString)
    End If
    

    In Page_Prerender

    ViewState("rcdupdate") = Session("rcdupdate")
    

    And in the Save routine

    If Session("rcdupdate").ToString = ViewState("rcdupdate").ToString Then
       ... write the data to the database ...
       Session("rcdupdate") = Server.UrlEncode(System.DateTime.Now.ToString)
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net page with a button. This button generates and inserts a
I have this ASP.NET/SQLServer2005 website running on a production server (Win2003, QuadCore, 4GB). The
In my ASP.NET applications, I have a server-side HTML select control. <select id=CompanyDropDown runat=server
I have an asp.net page with a save button within an updatepanel and contenttemplate.
I have an asp.net app with an asp:button that causes a postback, this means
So I have this ASP.Net 2.0 website that uses functions contained within a JS
I have this exact issue ASP.net can’t update page from event handler and it's
everybody; I have this problem in asp.net, I have a page where I insert
I have this problem in my ASP.NET application where I'm seeing some of my
I have this sort of format asp.net MVC View -> Service Layer -> Repository.

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.