Is it a good practice to use a user control inside a web part?
User control itself inherits from CMSAbstractWebPart.
We have a user control inside an update panel which is inside a web part, something like this:
<%@ Register Src="~/CMSWebParts/Custom/SomeUserControl/Add.ascx" TagPrefix="ucsfl" TagName="SomeControl" %> .... .... <cms:CMSUpdatePanel ID="udpReading" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false"> <ContentTemplate> <ucsfl:SomeControl runat="server" ID="someID" /> ... some other html code ... </ContentTemplate> </cms:CMSUpdatePanel>
The user control itself has an update panel with a link button.
<cms:CMSUpdatePanel runat="server" ID="AddToFavoritesUpdatePanel" UpdateMode="Conditional"> <ContentTemplate> <asp:LinkButton ID="lnkAdd" runat="server" OnClick="lnkAdd_Click"></asp:LinkButton> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="lnkAdd" EventName="Click" /> </Triggers> </cms:CMSUpdatePanel>
The problem is, when the lnkAdd button is clicked, the whole web part loads as an AJAX call instead of loading only the user control. The code on link button simply adds a record in database.
What are we doing wrong here?
Looks like this link has some answer, can you please help me understand it more.
https://devnet.kentico.com/questions/webpart-onload-of-child-is-calling-onload-of-parent-kentico-in-background
Please, sign in to be able to submit a new answer.