views:

12

answers:

2

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.

A: 

Hey,

It doesn't quite work like that no... why would you want to do that anyway?

Brian
A: 

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.

Jim