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

  • Home
  • SEARCH
  • 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 8214909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:36:39+00:00 2026-06-07T11:36:39+00:00

When I click on a button and add a control to a Placeholder inside

  • 0

When I click on a button and add a control to a Placeholder inside an UpdatePanel, everything is fine, except when I click really quickly several times and then get an error message like the following:

'Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Multiple controls with the same ID 'VehicleRegistrationEnhancedTextBox3_Label' were found. FindControl requires that controls have unique IDs.' when calling method: [nsIDOMEventListener::handleEvent]
[Break On This Error]   

I save an integer in a hidden field, to create unique Ids, when I click really fast, the method executes several times, but the count value has not yet updated. I tried using the C# lock keyword, but that did nothing.

The code is below:

protected void AddVehicleButton_Click(object sender, EventArgs e)
        {
            lock (this)
            {
                int count = Convert.ToInt32(VehicleRegistrationCountHiddenField.Value);

                var TBId = "VehicleRegistrationEnhancedTextBox" + count;
                IList<Panel> oldPanels = (IList<Panel>)Session["VehiclePanels"] ?? new List<Panel>();

                //Seperator
                Literal hr = new Literal { Text = "<hr/>" };

                //RemoveSpan
                Literal span = new Literal() { Text = "<span class=\"RemoveVehicleRegistration\">X</span>" };

                //Crop
                Control uc = LoadControl("~/Controls/ImageUploadAndCrop/ImageUploadAndCrop.ascx");
                uc.ID = "VehicleRegistrationImageUploadAndCrop" + count;

                //Vehicle Registration
                Label vehicleRegistration = new Label
                {
                    ID = TBId + "_Label",
                    AssociatedControlID = TBId,
                    Text = "Vehicle Registration:"
                };
                EnhancedTextBox vehicleTypeTextBox = new EnhancedTextBox
                {
                    ID = TBId,
                    Required = true,
                    RequiredErrorText = "Vehicle Registration is a required field."
                };

                //Add new controls to the form
                Panel newPanel = new Panel();

                newPanel.Controls.Add(hr);
                newPanel.Controls.Add(span);
                newPanel.Controls.Add(vehicleRegistration);
                newPanel.Controls.Add(uc);
                newPanel.Controls.Add(vehicleTypeTextBox);

                AddVehiclePlaceholder.Controls.Add(newPanel);

                //Increment the ID count
                count++;
                VehicleRegistrationCountHiddenField.Value = count.ToString();

                //Save the panel to the Session.
                oldPanels.Add(newPanel);
                Session["VehiclePanels"] = oldPanels;

                //Go back to the same wizard step.
                ShowStep2HiddenField.Value = "true";
                ShowStep3HiddenField.Value = "false";
            }
        }
  • 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-06-07T11:36:41+00:00Added an answer on June 7, 2026 at 11:36 am

    The problem is you are kicking of several postbacks with the same request, then the last response is what’s updating your update panel div, causing your issue. One possible solution is to include some javascript to disable your button on click.

    <asp:Button ID="myUpdatePanelPostBackButton" runat="server" OnClientClick="this.disabled=true; return true;" Text="Submit" />
    

    Assuming your button is within your UpdatePanel, when the update panel comes back, the button will be re-enabled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to add button click event by clicking design of axml? if
I am trying to click a button and add a resistor. So what I
When I click on Add button , the formAddNewRow form opens , but I
On a click of a button named Add Textbox it calls a function which
I want to add a click able button to a MKAnnotation as seen in
I want to add a ZedGraph when I click a button, but the ZedGraph
I managed to write add program that upon the user click a button, he
I want to add a UIViewController on my current UIView on a button click
This code works anywhere else.. form load, button click, etc. But when I add
i have a dropdownlist (asp.net control) and a listbox control and a Add button

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.