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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:58:20+00:00 2026-05-26T20:58:20+00:00

I am running into a problem with Ajax and C# asp.net. I am using

  • 0

I am running into a problem with Ajax and C# asp.net. I am using Microsoft Visual Studio 2010.

First let me explain my web page.

I have script manager, and directly underneath that I have a update panel.

This is the dynamic placeholder I’ve been fiddling with.

http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx

Within my update panel, I have a dynamic control & a button.

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="ScriptManager1" runat="server" >
    </asp:ScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">

        <ContentTemplate>
                <DBWC:DynamicControlsPlaceholder ID="DynamicControlsPlaceholder1" 
    runat="server">
            </DBWC:DynamicControlsPlaceholder>
            <br />

             <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

        </ContentTemplate>

        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
        </Triggers>

    </asp:UpdatePanel>

</asp:Content>

Now in my code behind:

I simply add 5 text boxes to a dynamic control. Page load;

protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            ViewState["id"] = 0;
        int id = (int)ViewState["id"];

        for (int i = 0; i < 5; i++)
        {
            id++;
            TextBox txt = new TextBox();
            txt.ID = id.ToString();
            DynamicControlsPlaceholder1.Controls.Add(txt);
            txt.Text = i.ToString();
        }
        ViewState["id"] = id;
        }

    }

Now all my button does is add another TextBox to the dynamic control pannel.

protected void Button1_Click(object sender, EventArgs e)
    {


        int id = (int)ViewState["id"];

        TextBox txt = new TextBox();
        txt.ID = id.ToString();
        DynamicControlsPlaceholder1.Controls.Add(txt);
        // DynamicControlsPlaceholder1.DataBind();
        txt.Text = id.ToString();

        id++;
       ViewState["id"] = id;

    }

* Note I am using a custom dynamic control panel so their ID’s are saved to the next page even though we have them creeated in a !Page.IsPostBack

The problem is that my button event handler only works once. I’m pretty sure its because the Ajax is calling a partial postback and it’s not recognizing it to call my button event handler.

I’m not sure, any help is appriciated.

  • 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-26T20:58:21+00:00Added an answer on May 26, 2026 at 8:58 pm

    Firebug works wonders for debugging ajax. “There were multiple controls with the same ID ‘5’.”

    What a simple fix. Moved id++; to the top of Button1_Click event handler.

    If you’re ever assuming ajax is breaking your event handler just because the breakpoint is not firing in the event handler, firebug may save you too!

    There was absolutely nothing wrong with the event handler, but the code within it was causing an error and ajax wasn’t allowing it to break.

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

Sidebar

Related Questions

I am running into a problem trying to use AJAX and jQuery with ASP.NET
I'm running into a problem while running both a Flash socket and using Ajax
Been running into this problem lately... When debugging an app in VS.Net 2005, breakpoints
Our web application started out as a big, honkin' ASP.NET AJAX 'page' with oodles
I am running into a bit of a problem in debugging a web application
This is my first attempt at AJAX, and I'm running into three specific problems.
I'm running into a problem with axis2 and ajax. I'm getting xml from one
I'm just building a simple ajax site but running into a problem in safari
While trying to implement some jQuery UI Tabs using AJAX I keep running into
Running into a problem where on certain servers we get an error that the

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.