Using Multiview inside UpdatePanel (doesn't update the view!)

吃可爱长大的小学妹 提交于 2019-12-11 06:07:26

问题


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">

<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>

    </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);
        }
   }

来源:https://stackoverflow.com/questions/1311445/using-multiview-inside-updatepanel-doesnt-update-the-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!