MultiView + UpdatePanel =不工作

时间:2013-05-16 12:33:59

标签: c# asp.net ajax webforms multiview

我正在使用RadioButtonList实现多视图以翻转其视图以及AJAX。

我的问题是如果我设置我的默认RadioButton(NavigateRadioButtonList.Items [0] .Selected = true;),那个RadioButton会变坏,即。当我专注于它时,MultiView根本没有响应。 这只发生在AJAX中。普通的asp页面没有这个问题。

我在我的智慧结束。有些专家可以帮忙吗? 代码如下

<%@ Page Language="C#" %>
<!DOCTYPE html>

<script runat="server">

    protected void Page_Init(object sender, EventArgs e)
    {
        for (int i = 1; i < 8; i++)
        {
            string RadioText = "View" + i.ToString();

            NavigateRadioButtonList.Items.Add(RadioText);


            Literal DescriptionTag = new Literal();
            DescriptionTag.Text = "Text" + i.ToString();
            View NewView = new View();
            NewView.Controls.Add(DescriptionTag);
            MultiViewMenu.Views.Add(NewView);
        }

    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            NavigateRadioButtonList.Items[0].Selected = true;
            MultiViewMenu.ActiveViewIndex = 0;
        }
    }

    protected void ChangeView(object sender, EventArgs e)
    {

        MultiViewMenu.ActiveViewIndex = NavigateRadioButtonList.SelectedIndex;

    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

        <asp:RadioButtonList ID="NavigateRadioButtonList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ChangeView"></asp:RadioButtonList>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:MultiView ID="MultiViewMenu" runat="server">
                </asp:MultiView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="NavigateRadioButtonList" EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
    </form>
</body>
</html>

0 个答案:

没有答案