title: Count every Button clicks
body: <p>The task is to count the number of clicks in a webform.</p>
  
  <p>Here is the code.</p>
  
  <pre><code>public partial class _default : System.Web.UI.Page
      {
          int count = 1;
          private void Page_Load(object sender, System.EventArgs e)
          {
              Button btn = new Button();
              btn.Text = "Click Me";
              btn.Click  += btn_Click;
              Label lbl = new Label();
              form1.Controls.Add(btn);
              form1.Controls.Add(lbl);
  
  
          }
  
          protected void btn_Click(object sender, EventArgs e)
          {
              count++;
              //Label1.Text = count.ToString();
  
          }
      }
  </code></pre>
  
  <p>The problem is that <strong>lbl</strong> is not recognised inside <strong>btn_Click()</strong> ... I can't figure it out... can anyone suggest?</p>