views:

49

answers:

1

Hello,

I've just made my first WebControl, but I'm having some troubles.

Here's a sample of what I have so far:

public class NotificationPopup : WebControl
{
    public bool? IsAccepted { get; set; }

    public void Show()
    {
        Panel root = new Panel();
        Button b1 = new Button();
        b1.Text = "Ok";
        b1.Click += delegate
        {
            IsAccepted = true;
        };
        Button b2 = new Button();
        b2.Text = "Cancel";
        b2.Click += delegate
        {
            IsAccepted = false;
        };
        Controls.Add(root);
    }
}

When I call Show the panel is displayed, but when I press the button the IsAccepted property is never changed. Can anyone tell me what I'm doing wrong?

+1  A: 

Do you re-create your buttons by calling Show again ? If you don't, the buttons are not created and the event handlers will not fire.

Locksfree