title: How to check if button was click in page load
body: <p>I have a button I don't want causing this if command in my page load.</p>
  
  <pre><code>If Page.IsPostBack Then
          ViewState(2) = TreeView1.SelectedNode.ValuePath
          ViewState(5) = TextBox1.Text
         ''Where I would like to put another if command or whatever else is possible to check if the buttong was clicked''
          If ViewState(2) = ViewState(1) And ViewState(5) = ViewState(4) Then
              nodecount = ViewState(3)
              nodecount = nodecount + 1
              ViewState(3) = nodecount
              If nodecount &gt; 0 Then
                  MsgBox("Please select another option or different number of data points")
  
              End If
  
          Else
              nodecount = 0
              ViewState(3) = nodecount
          End If
      End If
  </code></pre>
  
  <p>I tried setting a public property to change if the button was clicked but page.ispostback gets called first then the sub does.</p>