Update panel duplicating my controls

My code is as follows:

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnAddIsotope" EventName="Click" /> </Triggers> <ContentTemplate> <asp:gridview id="gwResults" runat="server"> 'all gridview columns go here </asp:gridview> <asp:ObjectDataSource here> <asp:Panel id="pnlAddIso" runat="server"> <asp:Textbox ID="txtIsoDate" runat="server" /> <asp:Button ID="btnAdd" Text="Add " CssClass="button" runat="server" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> 

when I click the button, it should add the element from txtIsoDate to the database and update the gridview.

he adds a penalty, but when he returns, he creates another copy of my pnlAddIso.

Why is this happening? I am very puzzled. please, help.

if im my button I write pnlAddIso.visible = false, the new duplicate panel does not appear, but the old one does not work anymore.

+4
source share
4 answers

I had the same problem, but I didn’t have the tables that I found, div tags were closed, problems were removed and fixed.

+9
source

The problem was in the tables.

I deleted all the table tags and now it works fine.

+1
source

I also experienced this problem, and as Servy said, the problem seems to be related to tables. This was consistent on every page.

The first thing I'm trying to do is update AjaxControlToolkit using NuGet.

In my case, the table encapsulated the update panel.

 <table> <asp:updatepanel .../> </table> 

I would look at your control or page and check if any structure would be interrupted by the anb update panel in this way.

+1
source

try it

When you click the button, ajax duplicates some controls.

 ScriptManager.GetCurrent(Page).RegisterPostBackControl(yourcontrol) 
0
source

Source: https://habr.com/ru/post/1341352/


All Articles