title: How to check if button is clicked or not in method?
body: <p>I want to check if button is clicked or not in method</p>
  
  <p>I tried but it's not working</p>
  
  <p>Code:</p>
  
  <pre><code>protected override void LoadViewState(object savedState)
  {
      base.LoadViewState(savedState);
  
      //Here If (btnAddExperience_Click()  is clicked)   
      {
      GenerateControls();
      } 
  
      GenerateControls1();
  }
  
  
  private void GenerateControls()
  {
      foreach (string i in NoOfControls)
      {
          VisaUserControl ctrl = (VisaUserControl)Page.LoadControl("VisaUserControl.ascx");
  
          ctrl.ID = i;
          this.rpt1.Controls.Add(ctrl);
          rpt1.Controls.Add(new LiteralControl("&lt;BR&gt;"));
      }
  }
  
  protected void btnAddVisa_Click(object sender, EventArgs e)
  {
      Button thisButton = (Button)sender;
      List&lt;string&gt; temp = null;
      var uc = (VisaUserControl)this.LoadControl(@"VisaUserControl.ascx");
  
      string id = Guid.NewGuid().ToString();
      uc.ID = id;
  
      temp = NoOfControls;
      temp.Add(id);
      NoOfControls = temp;
      rpt1.Controls.Add(uc);
      rpt1.Controls.Add(new LiteralControl("&lt;BR&gt;"));
  }
  
  private void GenerateControls1()
  {
      foreach (string i in NoOfControls)
      {
          ExperienceUserControl ctrl = (ExperienceUserControl)Page.LoadControl("ExperienceUserControl.ascx");
  
          ctrl.ID = i;
          this.rpt1.Controls.Add(ctrl);
          rpt2.Controls.Add(new LiteralControl("&lt;BR&gt;"));
      }
  }
  
  protected void btnAddExperience_Click(object sender, EventArgs e)
  {
      List&lt;string&gt; temp = null;
      var uc = (ExperienceUserControl)this.LoadControl(@"ExperienceUserControl.ascx");
  
      string id = Guid.NewGuid().ToString();
      uc.ID = id;
  
      temp = NoOfControls;
      temp.Add(id);
      NoOfControls = temp;
      rpt2.Controls.Add(uc);
      rpt2.Controls.Add(new LiteralControl("&lt;BR&gt;"));
  }
  </code></pre>
  
  <p>Any ideas? Thanks in advance</p>