2010-08-20 23 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 

也许不是“最佳实践”,但它的工作对我所需要的。