【问题标题】:Can you switch from Async PostBack to Full PostBack in an Update Panel?您可以在更新面板中从异步回发切换到完整回发吗?
【发布时间】:2010-08-20 18:13:22
【问题描述】:

这样的事情可能吗?

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

我是这个概念的新手,我觉得一定有一些我很容易错过的东西。

【问题讨论】:

    标签: asp.net asynchronous updatepanel


    【解决方案1】:

    没有说明原因,我最终所做的是将计数器存储在会话变量中,并从 for 循环中退出子程序,除非计数器等于数量。

    然后,我需要更新 for 循环结束后的所有内容(标签、DropDownBoxes),我将其放入他们自己的更新面板中,并将 UpdateMode 设置为 always。

    修改我上面的伪代码:

    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
    

    也许不是“最佳实践”,但它可以满足我的需要。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      • 1970-01-01
      • 2013-02-12
      • 2011-04-19
      • 2011-09-28
      • 2013-06-30
      • 1970-01-01
      相关资源
      最近更新 更多