Question

I have an UpdatePanel which is triggered by a Menu control (MenuItemClick). In the UpdatePanel, there is a Repeater with XML data source. Upon a menu item click, the XPath of Repeater's XML data source would be updated and the repeater would display the updated data.

The problem is, the UpdatePanel only gets updated/refreshed once. The 2nd click onward (on the menu item) would still trigger post backs and the data is correctly returned (seen from Firebug), but the UpdatePanel is not displaying the data passed back.

<asp:Menu runat="server" Orientation="Horizontal" RenderingMode="List" 
    EnableTheming="False" ID="MenuBar" MaximumDynamicDisplayLevels="0"
    StaticDisplayLevels="1" DataSourceID="xdsSiteMap" 
    onmenuitemclick="TabBar_MenuItemClick">
    <DataBindings>
        <asp:MenuItemBinding DataMember="siteMapNode" TextField="title" ValueField="value" />
    </DataBindings>
</asp:Menu>
<asp:XmlDataSource ID="xdsSiteMap" runat="server" 
    DataFile="SiteMap.xml" XPath="SiteMap/siteMapNode">
</asp:XmlDataSource>

<asp:UpdatePanel runat="server" ID="upp">
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="MenuBar" />
</Triggers>
<ContentTemplate>
    <asp:XmlDataSource ID="xdsData" runat="server" 
        DataFile="LinkData.xml" XPath="Links[@value='step1']"></asp:XmlDataSource>
    <asp:Repeater runat="server" ID="repeater" dataSourceID="xdsData">
    <ItemTemplate>
       <a href="<%#XPath("@url") %>"><%#XPath("Desc") %></a>
    </ItemTemplate>
    </asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>

Code-behind:

    protected void TabBar_MenuItemClick(object sender, MenuEventArgs e)
    {
        xdsData.XPath = "Links[@value='" + e.Item.Value + "']";
    }
Was it helpful?

Solution 2

It turns out to be a JavaScript fault with an observer function for each page load:

        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_pageLoaded(function (sender, args) {
            // some exception is generated here
        });

OTHER TIPS

The asp:menu where you are executing the click event from is not contained within the update panel, not sure that this is the problem directly, but it makes me wonder if the postback is happening asynchronously at all at this point. Try enclosing the asp:menu within the update panel and see what happens.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top