我有一個按鈕我不希望如果在我的頁面加載命令導致這種情況。如何檢查按鈕是否在頁面加載中被點擊
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
我試着設置一個公共屬性來改變,如果按鈕被點擊,但page.ispostback首先被調用,然後子。
相似的問題,http://stackoverflow.com/questions/11333305/asp-net-determine-which-button-was-clicked-inside-an-updatepanel-in-page-load-ev – Kratz
不是真的加上事實上它沒有回答。 –
從Kratz的上述鏈接中的第一個答案確實可行 - 只需在'If Page.IsPostBack'中調用'getPostBackControlID'函數,然後將輸出與按鈕的ID進行比較。 – Chaithanya