ASP.net: dynamic loading of web users

I have an asp.net webpage with place owner control and menu control when the user selects an item from the menu. It will dynamically load the control based on the value of the menu item.

I loaded the control, but if I click the link button or something on the web user control (.ascx), the user user control (.ascx) will disappear. I do not know what causes this. Can someone take a look at my code and see what I am missing?

Protected Sub Menu1_Click(ByVal sender As Object, ByVal e As EventArgs)

    Select Case Me.Menu1.SelectedValue
        Case "CustMasterMain"
            Dim ccCustMasterMaint As UserControl = CType(Page.LoadControl("~/Controls/Franchise/CustMasterMaintControl.ascx"), UserControl)
            Me.phHolder1.Controls.Add(ccCustMasterMaint)
        Case "AcctRecInq"
            Dim ccAcctRecInq As UserControl = CType(Page.LoadControl("~/Controls/Franchise/custAccountsReceivableInquiry.ascx"), UserControl)
            Me.phHolder1.Controls.Add(ccAcctRecInq)
    End Select

End Sub
+1
source share
2 answers

, , , . , .

, , ViewState , Load. Init PreInit.

+10

Joel , , , .

Dynamic Controls Placeholder - , . , , .

+2

All Articles