Discussion Locked

.NET Delegation

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

I have a dynamically created image button in a user control.

I would like to have the image button fire an event on the main web form. Is this possible - so far I cannot find any way to access the method.

Tks in advance.

3 replies

by jason_sahai

what is the event? A subroutine, function?

try this

if the image button name is "ImageButton1" without the quotes, then:

Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

' your subroutine here
MySub()

End Sub

basically when you click the button whatever code is written in the MySub() executes..

is this what your looking for?

by amoljpatil

write the method : private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
// do some thing.
}

add the delegate into InitializeComponent():

this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);

hope this will work.

cherrs:

Amol

by rrv

Add the delegate definition.
Add the subroutine to be called in Me.Initialise

Search for Threads and Delegation in MSDN to find sample code.
RV

This discussion is closed to new replies.