User control event problem (asp.net)

D

dllhell

Hello,

I have created a custom user control with one asp button on it but, when I
place this control on desired form, I can't see any events and no events
created after dubleclick on button in this control. I cearched on the
Internet but didn't find a soultion...
Can anyione explain what is needed to do if I want to see a button click
event of such control placed on the web form?
 
H

Hans Kesting

dllhell wrote on 22-1-2009 :
Hello,

I have created a custom user control with one asp button on it but, when I
place this control on desired form, I can't see any events and no events
created after dubleclick on button in this control. I cearched on the
Internet but didn't find a soultion...
Can anyione explain what is needed to do if I want to see a button click
event of such control placed on the web form?

If I understand correctly, you have a usercontrol placed on a form, and
in that form you want to react to clicks on a button inside that
usercontrol.

That will not work, the events of that button are not automatically
available on the usercontrol.

You will need to handle the button-click in the usercontrol itself. But
nothing is stopping to to define a "Click" event on the usercontrol
that gets fired when the button is clicked.

Hans Kesting

By the way, asp.net questions should go in the dotnet.framework.aspnet
newsgroup - more chance of getting an answer.
 
K

Ken Foskey

Hello,

I have created a custom user control with one asp button on it but, when
I place this control on desired form, I can't see any events and no
events created after dubleclick on button in this control. I cearched on
the Internet but didn't find a soultion... Can anyione explain what is
needed to do if I want to see a button click event of such control
placed on the web form?


I have a series of controls created by program control in a class that
then attaches the controls to a panel that is on an actual form.

I solved a problem similar to the above by creating a series of events
that are exactly the same as the ones I wanted and simply passed them
through. I don't have exact code so poetic license:

class MyControl
{
eventhandler MouseClick;

public void MyButtonCreate()
{
....
button.MouseClick = new event( MycontrolMouseClick);
....
}

MycontrolMouseClick( object sender, mouseclickevent e )
{
if( MouseClick != null )
MouseClick( sender, e );

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top