KMusatoff
asked on
ASP.NET Dynamic User Control Fire Parent Event in VB
I have a parent page with a simple code to load user controls. The question that I have is how can I fire MenuLinkButton_Click() on parent from loaded user control (any loaded user control) without explicitly declaring that user control on parent page?
Code provided...
Thank You
Kevin
Code provided...
Thank You
Kevin
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
LoadUserControl()
End Sub
Protected Sub MenuLinkButton_Click(ByVal sender As Object, ByVal e As CommandEventArgs)
If Not String.IsNullOrEmpty(e.CommandName) Then LastLoadedControl = BASE_PATH & e.CommandName & ".ascx"
LoadUserControl()
End Sub
Private Sub LoadUserControl()
Dim controlPath As String = LastLoadedControl
Dim bodyPlaceHolder As ContentPlaceHolder = Master.FindControl("body")
If Not String.IsNullOrEmpty(controlPath) Then
bodyPlaceHolder.Controls.Clear()
Dim uc As Control = Page.LoadControl(controlPath)
uc.ID = "loadedControl"
bodyPlaceHolder.Controls.Add(uc)
End If
End Sub
ASKER
The idea is to run Sub MenuLinkButton_Click() on parent
from your page
try to find the control in your parent
then yourControl.Click(sender,e )
try to find the control in your parent
then yourControl.Click(sender,e
convert to the template .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Self founded solution
MainForm.Controls(Parent).