tags:

views:

1020

answers:

0

Hi.

I have a simple test app to test if its possible to change the active view in a Multiview control in an Ajax manner. I've used UpdatePanel for that. The request is made in an Ajax maner. The active view is changed in code, but I don't see the result in the client browser! It never changes the activeview.

heres the example code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="tabsTest2.aspx.cs" Inherits="tabsTest2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

    </div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
     <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
          <asp:ListItem Value="0">View 1</asp:ListItem>
                <asp:ListItem Value="1">View 2</asp:ListItem>

    </asp:DropDownList>
    <asp:MultiView ID="MultiView1" runat="server">
        <asp:View ID="View1" runat="server">
            <asp:Button ID="Button1" runat="server" Text="Button" />
            view1
        </asp:View><asp:View ID="View2" runat="server">
            view2
    </asp:View>
    </asp:MultiView>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="DropDownList1" />
    </Triggers>
    </asp:UpdatePanel>


    </form>
</body>
</html>

public partial class tabsTest2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {

    }
    protected void DropDownList1_SelectedIndexChanged(object

sender, EventArgs e) {

        MultiView1.ActiveViewIndex = Convert.ToInt16(DropDownList1.SelectedValue);
    }
}

related questions