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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:16:12+00:00 2026-05-16T06:16:12+00:00

I’m working on a ASP.NET site with C# code. Now the trouble starts when

  • 0

I’m working on a ASP.NET site with C# code.
Now the trouble starts when I create a custom control programmatically. The control displays in a panel, but when I click one of the buttons of the control it does nothing. If I click them twice, the user control disappears.
Using the debugger, I found that it’s doing a postback, which is strange because I tried using buttons and setting the usesubmitbehavior to false; it’s still sending postbacks.

Here is where the control is inserted on the default.aspx file

<asp:UpdatePanel runat="server" ID="contentHolderUpdatePanel"
                UpdateMode="Conditional">
   <ContentTemplate>
       <asp:Panel runat="server" ID="contentPanel">
       </asp:Panel>
   </ContentTemplate>
</asp:UpdatePanel>

Here is the ASPX from ListadoAuditoria of the control.

<asp:UpdatePanel runat="server" ID="auditorTableUpdatePanel" UpdateMode="Conditional">
 <ContentTemplate>
     <asp:Table runat="server" ID="auditorTable" BorderWidth="0" Width="100%">
         <asp:TableHeaderRow HorizontalAlign="Center">
             <asp:TableHeaderCell>Button
             </asp:TableHeaderCell>
         </asp:TableHeaderRow>
     </asp:Table>
 </ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="formHolderUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" ID="testLabel" Text="bbbbbbbbbbbbb" ></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>

The method that the button invokes should change the text of the label testLabel from “bbbbbbbbbbbbb” to “aaaaaaaaaaa”. Obviously I’m doing an auditorTableUpdatePanel.Update() after I modify the text.

The control CS

    protected void Page_Load(object sender, EventArgs e)
    {
        loadAudits();
    }

    public void loadAudits()
    {

        for(int i=0;i<10;++i)
        {
            TableRow row = new TableRow();

            TableCell cell1 = new TableCell();

            ImageButton deleteButton = new ImageButton();
            deleteButton.ImageUrl = "~/image.gif";
            deleteButton.Click += generateNewPart;
            deleteButton.EnableViewState = true;
            deleteButton.ID = i.ToString();

            cell1.Controls.Add(deleteButton);

            row.Cells.Add(cell1);

            auditorTable.Rows.Add(row);

        }
    }

    public void generateNewPart(object sender, EventArgs e)
    {
        tumadre.Text = "aaaaaaaaaaaa";
        formHolderUpdatePanel.Update();
    }

And here is the code when I generate the control and insert it into the panel:

Panel panel = (Panel)Page.FindControl("contentPanel");
UpdatePanel updatePanel = (UpdatePanel)Page.FindControl("contentHolderUpdatePanel");
ListadoAuditorias listadoAuditorias = (ListadoAuditorias)LoadControl("~/CargaDeAuditoria/ListadoAuditorias.ascx");
panel.Controls.Add(listadoAuditorias);
updatePanel.Update();

I looked over the Internet and didn’t found anything.

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

    I’m not sure where exactly the code to dynamically add the controls is, but it must be called on EVERY postback to re-add the controls. You can’t just add it once and forget about it. When you postback, the page will re-render with the markup in your aspx page (which does not have your dynamic controls, obviously). The values from the dynamically added controls will still be in ViewState, but the controls will not be re-rendered.

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

Sidebar

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.