你可以在更新面板中从Async PostBack切换到Full PostBack吗?

时间:2010-08-20 18:13:22

标签: asp.net asynchronous updatepanel

这样的事情可能吗?

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

我对这个概念不熟悉,并且觉得必须有一些我很遗憾的东西。

1 个答案:

答案 0 :(得分:0)

没有进入原因,我最终做的是将计数器存储在会话变量中并从for循环退出sub,除非计数器等于数量。

然后我需要更新的for循环结束的所有内容(Labels,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

也许不是'最佳实践',但它适用于我需要的东西。