0

我正在使用 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>
4

0 回答 0