F
Franck
Hello,
I wrote my proper web control using a button and a few other components
in order to allow the page iclunding the control to capture the click
event from the button
i did that
//class declaration
public class ButtonDreamWeaver : Control, INamingContainer
public event EventHandler PicClicked;
// button creation
protected override void CreateChildControls()
{
// the button
imgBtnState= new ImageButton();
imgBtnState.ImageUrl=imgStatic;
imgBtnState.Click+=new ImageClickEventHandler(imgBtnState_Click);
// adding the button to this control
this.Controls.Add(imgBtnState);
}
// capturing the event
protected override void CreateChildControls()
{
[............]
imgBtnState.Click
+=new ImageClickEventHandler(imgBtnState_Click);
}
//resending the event PicClicked
private void imgBtnState_Click(object sender, ImageClickEventArgs e)
{
PicClicked(this,e);
}
But if i don't register the event on the page,
I recieve a null reference exception so it forces my control to have its
event registered
Where am I wrong?
Thank you
I wrote my proper web control using a button and a few other components
in order to allow the page iclunding the control to capture the click
event from the button
i did that
//class declaration
public class ButtonDreamWeaver : Control, INamingContainer
public event EventHandler PicClicked;
// button creation
protected override void CreateChildControls()
{
// the button
imgBtnState= new ImageButton();
imgBtnState.ImageUrl=imgStatic;
imgBtnState.Click+=new ImageClickEventHandler(imgBtnState_Click);
// adding the button to this control
this.Controls.Add(imgBtnState);
}
// capturing the event
protected override void CreateChildControls()
{
[............]
imgBtnState.Click
+=new ImageClickEventHandler(imgBtnState_Click);
}
//resending the event PicClicked
private void imgBtnState_Click(object sender, ImageClickEventArgs e)
{
PicClicked(this,e);
}
But if i don't register the event on the page,
I recieve a null reference exception so it forces my control to have its
event registered
Where am I wrong?
Thank you