I’ve made a custom click event for a custom server control. The control is a button that has a linkbutton and normal button inside it. The event essentially provides a common click event for the link and normal button to fire if they themselves are clicked.
Here is my code:
public delegate void ButtonClick(object sender, EventArgs e);
public event ButtonClick Click;
protected virtual void OnClick(object sender, EventArgs e)
{
if (Click != null)
Click(sender, e);
}
void butButton_Click(object sender, EventArgs e)
{
OnClick(sender, e);
}
void lbuButton_Click(object sender, EventArgs e)
{
OnClick(sender, e);
}
Now on the page where I’m using the control:
void sbuSave_Click(object sender, EventArgs e)
{
// Cannot debug here! Can't check if event is fired.
}
Can I not debug inside my event because it’s not firing? If I do a Response.Write() inside it I get the text so I presume it’s firing. I really need to be able to debug inside my event due to what’s going on in the rest of the app. What’s going on here? Am I missing something vital?
See Polity’s comments, also make sure debugging is enabled in your web config. 😉