Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / March 2008

Tip: Looking for answers? Try searching our database.

Events in server controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
I am Sam - 16 Feb 2008 23:57 GMT
I need to write a composite control where a click event in the
parent(container) class fires an event in a child control.  How is this
possible?  ie clicking a button in the parent control performs an action on a
child control.
Teemu Keiski - 16 Mar 2008 17:57 GMT
Hi,

you could access the child control in button's click event? Or if it's
something internal in the child control, it should be informed somehow that
the Click occurred, maybe it could wire up to an event of the parent control
which the parent exposes publicly?

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

>I need to write a composite control where a click event in the
> parent(container) class fires an event in a child control.  How is this
> possible?  ie clicking a button in the parent control performs an action
> on a
> child control.
I am Sam - 16 Mar 2008 20:38 GMT
The solution is very simple really.  You can for example write the following:
protected override void CreateChildControls()
{
ImageButton someImageButton=new ImageButton();
someImageButton.Click += new ImageClickEventHandler(ImageButton_Click);
this.Controls.Add(someImageButton);
}

protected void ImageButton_Click(object sender, ImageClickEventArgs e)
{
do something..;
}

within your custom control.  You only want to bubble events when you want to
expose your event in the containing page.

> Hi,
>
[quoted text clipped - 8 lines]
> > on a
> > child control.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.