Saturday, March 24, 2012

UpdatePanel + MultiView + TreeView do not work

HI

I have simple master page having the ContentPlaceHolder inside an UpdatePanel.

<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>

My content page has a MultiView and Two View controls. Each View control has a TreeView inside. My problem is the TreeView in the first View can expand/collpase but the one in the second view has no response when clicking on it. What is going on?
<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TemplatedPage.aspx.cs" Inherits="TemplatedPage" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Button ID="Button1" runat="server" Text="Switch pane" OnClick="Button1_Click" /> <asp:MultiView ID="mv1" runat="server" ActiveViewIndex="0"> <asp:View ID="view1" runat="server"> <asp:TreeView ID="TreeView1" runat="server"> <Nodes> <asp:TreeNode Text="Tree 1" Value="Tree 1"> <asp:TreeNode Text="New Node" Value="New Node"></asp:TreeNode> </asp:TreeNode> </Nodes> </asp:TreeView> </asp:View> <asp:View ID="view2" runat="server"> <asp:TreeView ID="TreeView2" runat="server"> <Nodes> <asp:TreeNode Text="Tree2" Value="Tree2"> <asp:TreeNode Text="New Node" Value="New Node"></asp:TreeNode> </asp:TreeNode> </Nodes> </asp:TreeView> </asp:View> </asp:MultiView></asp:Content>

Code behind:

public partialclass TemplatedPage : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) {if (mv1.ActiveViewIndex == 0) mv1.ActiveViewIndex = 1;else mv1.ActiveViewIndex = 0; }}

From my limited knowledge treevie and menu controls are not currently supported in the ajax enviroment.. thus you will need to resort to a iframes approach or simply not place menu or treeview controls into a update panel. It is the Goal however of the Asp.Net to make all current .Net controls usable with the update panel but it won't most likely happend until the release of Orcas..

It is probably related to my problem with the Multiview control:

http://forums.asp.net/thread/1412888.aspx

No comments:

Post a Comment