I have a WebSplitter with two panes (left and right). In the right pane, is an UpdatePanel that wraps a grid control. There are a few buttons in the left pane. I am finding that, when using a WebSplitter, I cannot set the UpdatePanel triggers collection in the client side markup. Normally, I would do something like this:
<cc1:SplitterPane runat="server" Size="75%" enableRelativeLayout="true" style="position:relative" > <Template> <asp:UpdatePanel ID="updPanelView" runat="server" RenderMode="Inline"> <ContentTemplate> <div id="divView" runat="server" style="height: 100%; width: 100%; vertical-align: top;" align="left"> <uc1:View ID="View" runat="server" /> </div> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="cmdGo" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="igTree" EventName="NodeClicked" /> </Triggers> </asp:UpdatePanel> </Template> </cc1:SplitterPane>
<cc1:SplitterPane runat="server" Size="75%" enableRelativeLayout="true" style="position:relative" >
<Template>
<asp:UpdatePanel ID="updPanelView" runat="server" RenderMode="Inline">
<ContentTemplate>
<div id="divView" runat="server" style="height: 100%; width: 100%; vertical-align: top;"
align="left">
<uc1:View ID="View" runat="server" />
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cmdGo" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="igTree" EventName="NodeClicked" />
</Triggers>
</asp:UpdatePanel>
</Template>
</cc1:SplitterPane>
But, if I add the Triggers collection, I get the following error message:
A control with ID 'cmdGo' could not be found for the trigger in UpdatePanel 'updPanelView'
So, instead, I remove the Triggers collection and add them in the code-behind Page_Load, like this:
Dim trigger As New System.Web.UI.AsyncPostBackTrigger trigger.EventName = "Click"trigger.ControlID = Me.cmdGo.UniqueID.ToString Me.updPanelView.Triggers.Add(trigger)trigger = New System.Web.UI.AsyncPostBackTrigger trigger.EventName = "NodeClicked"trigger.ControlID = Me.igTree.UniqueID.ToString Me.updPanelView.Triggers.Add(trigger)
trigger.EventName = "Click"
Me.updPanelView.Triggers.Add(trigger)
trigger.EventName = "NodeClicked"
That gets past the first error. But, it only works every other event. In other words, the first time I hit the cmdGo button, the async postback works properly. The next time, I get a full page postback, then the next an async postback. And, so it goes.
Anyone experience similar problems? Solutions?
Thanks
Thank you Rumen, that appears to have solved the problem.
Hello,
Thanks for writing. I believe both issues you report might be the expected behaviour
1) Anything inside a Template (INamingContainer) cannot be accessed outside the template. I guess, if you try the same setup with any templated control you will get the same problem - declaratively you will not be able to set triggers. So your approach with code is I believe the correct way.
2) The second problem is I believe related to events/life-cycle of the ASP.NET page. Typically, events are setup in the OnInit event of the page (this is what VS.NET does under the hood when you use the designer) - and this might be related to the problem you are getting since Page_Load is called much later in the cycle.
So one thing I can suggest is moving your code initializing the UpdatePanel triggers to OnInit - this may address the problem.
Please, let me know if this works.