0

I have a button I don't want causing this if command in my page load.

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 > 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

I tried setting a public property to change if the button was clicked but page.ispostback gets called first then the sub does.

Drfrink
  • 404
  • 1
  • 9
  • 25
  • 1
    Similar question, http://stackoverflow.com/questions/11333305/asp-net-determine-which-button-was-clicked-inside-an-updatepanel-in-page-load-ev – Kratz Dec 07 '12 at 15:51
  • not really plus the fact it wasn't answered. – Drfrink Dec 07 '12 at 20:46
  • 1
    The first answer in the above link from Kratz does work - just call the `getPostBackControlID` function within `If Page.IsPostBack`, then compare the output with the button's id. – Chait Dec 07 '12 at 21:49

1 Answers1

0

I'm not sure if I fully understand your question. If you are trying to run a block of code, why not do it at the btnSomeButton.Click event, why do it at the Page_Load event.

Imad S.
  • 375
  • 3
  • 15