Exception when adding usercontrol more than once

1

Hello. I have a newsletter user control and it is added in several places within the project, for each page it is called, a property is set to insert the email into a certain group of emails (% with%). It turns out that now beyond the internal pages the same UC will be in GrupoEmailNewsletter , where it began to give problems.

In the master is registered and called:

<%@ Register Src="../UserControl/BoxNewsletter.ascx" TagName="BoxNewsletter" TagPrefix="uc3" %>
<uc3:BoxNewsletter ID="boxNewsletter" runat="server" GrupoEmailNewsletter="Geral" />

And the MasterPage page is also registered and called:

<%@ Register TagPrefix="uc5" Src="~/Include/UserControl/BoxNewsletter.ascx"  TagName="Newsletter" %>
<uc5:Newsletter id="ucNewsletter" runat="server" GrupoEmailNewsletter="GrupoA" />

When accessing the page GrupoA.aspx , the following error occurs:

ERRO DO SISTEMA:
Exceção do tipo 'System.Web.HttpUnhandledException' foi acionada.
Uma exceção foi acionada pelo destino de uma chamada.
Já existe uma entrada com a mesma chave.

I have found ids and have no matches. What else would this error be?

    
asked by anonymous 25.11.2016 / 13:29

1 answer

0

The%% of newsletter I developed has validations. I use UserControl to check if the field is empty. The pages that inherit from RequiredFieldValidator have MasterPage modified, the name validation components did not have UserControl modified, in this case I added the name property on the ClientIDMode="AutoID" components to change the id.

 <asp:RequiredFieldValidator ID="rfvNomeNewsletter" runat="server" Display="None"
    ErrorMessage="Informe seu nome." ControlToValidate="txtNomeNewsletter" SetFocusOnError="true"
    ValidationGroup="vgrNewsletter" ClientIDMode="AutoID"></asp:RequiredFieldValidator>

So, the id of the element that is on the page inherited from the master page is: RequiredFieldValidator Home The element that is in the masterpage: ctl00_cphMasterPortal_ucBoxNewsletter_rfvNomeNewsletter Home Not causing the duplicate ID error.

    
25.11.2016 / 17:42