Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.NET Dynamic User Control Fire Parent Event in VB

Posted on 2011-03-06
6
Medium Priority
?
706 Views
Last Modified: 2012-06-27
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

 
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

Open in new window

0
Comment
Question by:KMusatoff
6 Comments
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 35049953
Hi, try this code


MainForm.Controls(Parent).YourControlName
0
 
LVL 3

Author Comment

by:KMusatoff
ID: 35050974
The idea is to run Sub MenuLinkButton_Click() on parent
0
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 35053514
from your page
try to find the control in your parent
then yourControl.Click(sender,e)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:lalitgada
ID: 35053656
convert to the template .
0
 
LVL 3

Accepted Solution

by:
KMusatoff earned 0 total points
ID: 35064080
I do not have a control on parent I can trigger. The loaded control will have many linkButtons to trigger controls.

But, never the less, I have found the way...

 
Protected Sub ControlLinkButton_Click(ByVal sender As Object, ByVal e As CommandEventArgs)
    Dim p As Users_Default = CType(Context.Handler, Parent_Default) 'Parent_Default As Parent Page
    p.LastLoadedControl = e.CommandName
    p.LoadUserControl()
End Sub

Open in new window

0
 
LVL 3

Author Closing Comment

by:KMusatoff
ID: 35115463
Self founded solution
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question