Inherited Ascx

  • Thread starter Thread starter Jordan
  • Start date Start date
J

Jordan

I have created an ascx control that is a kind of custom panel with
specific code behind and a custom design. I have then created a new
ascx that inherit from my first ascx. The problem that I have is that
doing so, if I put a new control inside my inherited ascx and put code
behind this new control,this code will not execute.

So is there a way to create a child control an have the specific code
behind it execute and not just is parent code?

thanx
 
Jordan - yes, this is possible. Where is the code you want to execute?
In an event handler? In a virtual method? Perhaps you could post a
small example.
 
Here is a Small example:

My Parent Ascx contain a label with ID="lblText" and a button. the
button have this code behind:

Private Sub btnParent_Click(ByVal sender As system.Object, ByVal e
As System.EventArgs) Handles btnParent.Click
lblText.Text = "Text changed by parent button"
End Sub


My inherited ascx contain all the parent control but also a new button
with this code behind:


Private Sub btnChild_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnChild.Click
lblText.Text = "Text Changed by Child button"
End Sub

now if I put my inherited control on my page and I click on the Parent
Button the label will change. but if I click on the child button nothing
append. I also tried to to a breakpoint on my child button code and the
program never stopped when I clicked on my button.

Thanx
 
Jordan:

When you say inheritance - are you actually using the Inherits
keyword, or are you including the first UserControl inside of the
second ascx with a tag?
 
Back
Top