2012-12-07 2 views
0

버튼이 있습니다. 내 페이지로드시이 명령을 사용하지 않으려 고합니다. 버튼에서 페이지를 클릭했는지 확인하는 방법

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가 처음 호출되는 경우 변경 공용 속성을 설정했습니다.

+1

비슷한 질문 http://stackoverflow.com/questions/11333305/asp-net-determine-which-button-was-clicked-inside-an-updatepanel-in-page-load-ev – Kratz

+0

정말 플러스 사실 그것은 대답하지 못했습니다. –

+1

위의 Kratz 링크의 첫 번째 대답은 작동합니다. If Page.IsPostBack에서 'getPostBackControlID' 함수를 호출 한 다음 출력을 버튼의 ID와 비교하십시오. – Chaithanya

답변

0

질문을 완전히 이해할 수 있을지 잘 모르겠습니다. 코드 블록을 실행하려는 경우 btnSomeButton.Click 이벤트에서 코드를 실행하십시오. 왜 Page_Load 이벤트에서 수행해야합니까?

+0

그의 질문은 다른 방법이라고 생각합니다. 버튼을 클릭하면 실행하고 싶지 않은 PageLoad의 코드가 있습니다. – Kratz

+0

어쨌든 viewstates –

관련 문제