在UpdatePanel中使用Multiview(不更新视图!)

时间:2009-08-21 11:35:05

标签: asp.net-ajax

我有一个简单的测试应用程序来测试是否可以以Ajax方式更改Multiview控件中的活动视图。我已经使用了UpdatePanel。该请求是在Ajax maner中进行的。活动视图在代码中已更改,但我在客户端浏览器中看不到结果! 它永远不会改变活动视图。

见下示例代码:

    <%@ 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);
        }
   }

0 个答案:

没有答案