Difficulty hiding part of a form with UserControl

0

I have a form called frmCadastroBens that declares a UserControl, which I call wucCadastroBens. In this form I register the UC like this:

<%@ Register src="WUC/wucCadastroBens.ascx" tagname="wucCadastroBens" tagprefix="uc1" %>
<%@ Register src="WUC/wucCadastroBens.ascx" tagname="wucCadastroBens" tagprefix="uc2" %>
<%@ Register src="WUC/wucCadastroBens.ascx" tagname="wucCadastroBens" tagprefix="uc3" %>

And then like this:

<uc1:wucCadastroBens ID="wucCadastroBensNovoPV" runat="server" />
    <br />
    <uc2:wucCadastroBens ID="wucCadastroBensUsadosPV" runat="server" />
    <br />
    <asp:RadioButtonList RepeatDirection="Horizontal" ID="rdbGarantiaConfissao" runat="server" RepeatLayout="Flow" RepeatColumns="0" CellSpacing="-1">
        <asp:ListItem Text="Confissão de Dívida " Value="1"></asp:ListItem>
        <asp:ListItem Text="Garantia Adicional"  Value="2"></asp:ListItem>
    </asp:RadioButtonList>
    <uc3:wucCadastroBens ID="wucCadastroConfissaoDividaPV" runat="server" />

It turns out that I need, at the moment of clicking on the Register buttonNew, I hide the other UC, let me explain. It's just a UC, registered as I said above. When I'm in uc1, I should show the Registration Pane and hide the others. The problem is that a pane is only and this method is inside the wucCadastroBens.cs and not in frmCadastroBens.cs. If it was inside the frmCadastroBens.cs, I would do it like this: wucCadastroBensUsadosPV.Visible = false; this would work, but I happen to be inside the wuc and I can not have "3" "panels anymore, for example, as I have in frmCadastrBens. Then comes the question: How can I do it, so that at the time of registering a new good, I hide the other panels (one for each wuc registered in frmCadastroBens). At the moment when the page is loaded, the three panels appear.

    
asked by anonymous 02.02.2015 / 14:16

1 answer

1

Try the following: In frmCadastroBens.cs add a public method that changes the visibility of the UserControl.

public void setUCVisible(wucCadastroBens userControl) { ... }

Then inside the UserControl, do the following:

var parent = this.Parent.Page as frmCadastroBens;
parent.setUCVisible(this);
    
02.02.2015 / 14:38