This is a migrated thread and some comments may be shown as answers.

Some postbacks from dynamic controls are ignored

1 Answer 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dan Lehmann
Top achievements
Rank 1
Dan Lehmann asked on 18 Jul 2011, 09:54 PM
I'm using 2011_2_712 and have Uploaded a project here.

I'm using a RadTabStrip to dynamically load various User Controls. Events on these user controls sometimes take multiple firings for them to land on the event handlers.

To see this,
1. Put a breakpoint on the Select statement of rgOrders_ItemCommand()
2. Navigate to Default.aspx
3. Press "Select" for one of the customers. (The first one, Alfreds Futterkiste has orders)
4. Click the Orders tab.
5. Click Select for one of the orders.
Notice the postback is lost.

6. Press Select again and the postback is correct.

In my real project it takes 2 postbacks for one telerik control and 3 for another.  Can anyone make sense of this or tell me what I'm doing wrong?

Thanks,
Dan

1 Answer, 1 is accepted

Sort by
0
Dan Lehmann
Top achievements
Rank 1
answered on 18 Jul 2011, 10:17 PM
Found the solution here: http://www.velocityreviews.com/forums/t71158-events-not-firing-first-time-only-in-a-dynamic-user-control-please-help.html

Apparently ID's are required.. I fixed by adding the id like:
Private Function GetControl(ByVal index As Int32) As UserControl
    Dim ctrl As UserControl = Nothing
    Select Case index
        Case 0
            ctrl = LoadControl("Controls/Customer.ascx")
        Case 1
            ctrl = LoadControl("Controls/Orders.ascx")
           
    End Select
     ctrl.ID = "ucID" & index
    Return ctrl
End Function

Thanks,
Dan
Tags
General Discussions
Asked by
Dan Lehmann
Top achievements
Rank 1
Answers by
Dan Lehmann
Top achievements
Rank 1
Share this question
or