473,779 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inherited Ascx

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
Nov 18 '05 #1
3 1799
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.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 22 Nov 2004 08:22:02 -0800, tw*******@hotma il.com (Jordan) wrote:
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


Nov 18 '05 #2
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.EventArg s) 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.EventArg s) 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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
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?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 22 Nov 2004 09:21:14 -0800, Jordan <Jo****@program mer.net>
wrote:
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.EventArg s) 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.EventAr gs) 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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2521
by: Rob Meade | last post by:
Hi all, I have just put together our organisations 'template' for our web applications and have created 7 .ascx files which when dropped into my template file work perfectly...however, I have a question... As our team develops several applications I wanted these generic .ascx's to be able to be used by all - therefore I've placed them in the root of the domain we work on in a directory called /WebUserControls
0
923
by: Brandon Potter | last post by:
I am building a large template-based ASP.NET app using inheritance and loading user controls as the method of loading templates and populating them. I catch the requests for pages in Global.asax and load the desired page that inherits the (or an inherited class of) base template class. I have a top-template level class called TemplateControlBase that inherits from UserControl, a la: ---------------------------------------------- Public...
2
1303
by: Wade Beasley | last post by:
I have a web project that currently has a standard header, footer, and menu ascx files. I am now suppose to change the project to allow a user to choose from 3 different views, ie 3 different groups of those .ascx files. Does anyone have some sample code on how to do this? This needs to check once a user has signed in on which version to display. Thanks, Wade
1
3359
by: John Cosmas | last post by:
I've got a page which loads up a different user control into a placeholder control every time a button is clicked on the parent page. I use a statement like Me.plcTabViews.Controls.Add(LoadControl("test.ascx")). There are up to 30 possibilities which are decided by CASE statements and keeps one from loading up onto another. However, I'm running into a unique error... Failed to load viewstate. The control tree into which viewstate is...
6
2788
by: tshad | last post by:
I have an ascx file I am using to include my logos and heading information for all my pages. It was working fine up until now. I decided to set up an admin folder inside of my main folder and move one of my files into it - now my links don't work. I have a setup:
3
5483
by: Wayne Brantley | last post by:
VS2005 RTM Create a web user control to use as a base class for other web user controls. Now, create a new web user control, change the class it inherits from to your base class and compile. (You must have a <% Register %> so it will see it) You will get TWO warnings per class like:
2
1223
by: Peter Kirk | last post by:
Hi I have an ascx (MainCalendarControl.ascx), which includes another ascx, by using this statement at the top of MainCalendarControl.ascx: Register TagPrefix="CalendarUI" TagName="ActivityListControl" Src="ActivityCalendar.ActivityListControl.ascx" Then there are various tables etc in MainCalendarControl.ascx to display some data, and last:
0
1803
by: dkode | last post by:
Hello, I know this can be done, but it's beyond me at the moment, Here is my inheritance chain: class NavRole : UserControl { protected void AddSubmenu(string submenuFile);
3
5274
by: Steven Nagy | last post by:
Hi all, ASP.NET : Framework 2.0 - C# A recent addition to my code generater will create GridView's and ObjectDataSource's in a control (ASCX). So the code gen creates an ascx, ascx.cs, ascx.designer.cs and a stylesheet. The 3 control files are placed together.
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.