您可以在更新面板中从异步回发切换到完整回发吗?

发布于 2024-09-15 19:52:56 字数 370 浏览 4 评论 0原文

这样的事情可能吗?

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

我对这个概念很陌生,感觉一定有一些非常简单的东西我错过了。

Is something like this possible?

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

I am new to the concept and feel like there must be something really easy that I am missing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待圉鍢 2024-09-22 19:52:56

无需深究原因,我最终所做的是将计数器存储在会话变量中,并从 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

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

Without going into why, what I eventually did was store the counter in a session variable and exited the sub from the for loop unless the counter was equal to the quantity.

Then everything past the end of the for loop that I needed updated (Labels, DropDownBoxes) I put in their own update panels with UpdateMode set to always.

To modify my pseudo code above:

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

Maybe not the 'best practice' but it worked for what I needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文