I'm trying to employ the strongest OOP I can muster in developing a web application, but I'm having issues adding event handlers to my objects as I create them using code. I'm sure it's a fairly simple solution that I just keep passing up, but I'm at a loss as to what to try next. Below is some test code I've been playing with, just trying to get a button press to go do something.
(Imagine there's a break point on the line "int i;")
Button b = new Button();
b.Text = "Do Something";
b.Attributes.Add("runat", "server");
b.Attributes.Add("OnClick", "click");
form1.Controls.Add(b);
private void click(object sender, EventArgs e)
{
int i;
}
Since this is a new button created by my Page_Load, I can't just hardcode the XHTML. Debugging never hits my breakpoint. I haven't had any more success with CheckBoxes either.