2010-08-20 24 views
1

是這樣的可能嗎?可以在更新面板中將Async PostBack切換爲Full PostBack嗎?

Dim iCounter as Integer 
Dim iQuantity as Integer = 10 

Protected Sub btnFoo_Click Handles btnFoo Yadda 

    For i as Integer = iCounter to iQuantity - 1 
     //do something with AsyncPostBackTrigger until iCounter = iQuantity - 1 
     //then trigger a full postback 
    Next 

End Sub 

我是新來的概念,覺得必須有一些很容易丟失的東西。

回答

0

不用爲什麼,我最終做的是將計數器存儲在會話變量中,然後退出for循環的子計數,除非計數器等於數量。

然後,我需要更新的for循環末尾的所有內容(標籤,DropDownBoxes)我將UpdateMode設置爲始終置於其自己的更新面板中。

要修改我上面的僞代碼:

Dim iCounter as Integer = Session("counter") 
Dim iQuantity as Integer = 10 

Protected Sub btnFoo_Click Handles btnFoo Yadda 

    For i as Integer = iCounter to iQuantity - 1 
     //do something with AsyncPostBackTrigger until iCounter = iQuantity - 1 
     //then trigger a full postback 

     If iCounter <> iQuantity Then 
      Exit Sub 
     End If 
     Session("counter") = iCounter + 1 
    Next 

    //Everything else I needed to do with page controls wrapped 
    //in their own update panels 

End Sub 

也許不是「最佳實踐」,但它的工作對我所需要的。