0

Repeater 内にある AutoPostBack=true の RadioButtonList があります。リピーター全体が更新パネルに囲まれています。ただし、RadioButtonList によって完全なポストバックが発生します。

UpdatePanel もリピーター内にある他のシナリオを試しましたが、それでも同じ問題が発生します。

次のコードは、問題を示しています。

最初のラジオ ボタンは更新パネルの外側にあるため、完全なポストバックが発生するはずです。これは正しく動作します。

2 番目のラジオ ボタンは独自の更新パネル内にあり、部分的なポストバックが発生するはずです。これは正しく動作します。

3 番目のラジオ ボタンは、Update Panel 内にある Repeater 内にあります。これにより、部分的なポストバックが発生するはずですが、完全なポストバックが発生しています。

4 番目のラジオ ボタンは、Repeater 内の Update Panel 内にあります。これにより、部分的なポストバックも発生するはずですが、完全なポストバックが発生しています。

<%@ Page Language="C#" AutoEventWireup="true" %>
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            rptTest1.DataSource = Enumerable.Range(1, 1);
            rptTest1.DataBind();

            rptTest2.DataSource = Enumerable.Range(1, 1);
            rptTest2.DataBind();
        }
    }
</script>

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="script1" EnablePartialRendering="true" runat="server" />

    Date1: <%=System.DateTime.Now.ToString() %>
    <asp:RadioButtonList ID="rbl1" AutoPostBack="true" runat="server">
        <asp:ListItem>a</asp:ListItem>
        <asp:ListItem>b</asp:ListItem>
        <asp:ListItem>c</asp:ListItem>
    </asp:RadioButtonList>
    <br /><br />

    <asp:UpdatePanel runat="server" UpdateMode="Conditional">
        <ContentTemplate>

            Date2: <%=System.DateTime.Now.ToString() %>
            <asp:RadioButtonList ID="rbl2" AutoPostBack="true" runat="server">
                <asp:ListItem>a</asp:ListItem>
                <asp:ListItem>b</asp:ListItem>
                <asp:ListItem>c</asp:ListItem>
            </asp:RadioButtonList>
            <br /><br />
        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:UpdatePanel runat="server" id="upd1" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Repeater ID="rptTest1" runat="server">
                <ItemTemplate>
                    Date3: <%=System.DateTime.Now.ToString() %>
                    <asp:RadioButtonList ID="rbl3" AutoPostBack="true" runat="server">
                        <asp:ListItem>a</asp:ListItem>
                        <asp:ListItem>b</asp:ListItem>
                        <asp:ListItem>c</asp:ListItem>
                    </asp:RadioButtonList>
                    <br /><br />
                </ItemTemplate>
            </asp:Repeater>
        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:Repeater ID="rptTest2" runat="server">
        <ItemTemplate>
            <asp:UpdatePanel runat="server" id="upd2" UpdateMode="Conditional">
                <ContentTemplate>
                    Date4: <%=System.DateTime.Now.ToString() %>
                    <asp:RadioButtonList ID="rbl4" AutoPostBack="true" runat="server">
                        <asp:ListItem>a</asp:ListItem>
                        <asp:ListItem>b</asp:ListItem>
                        <asp:ListItem>c</asp:ListItem>
                    </asp:RadioButtonList>
                    <br /><br />
                </ContentTemplate>
            </asp:UpdatePanel>
        </ItemTemplate>
    </asp:Repeater>

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

ページ自体が大きく、結果としてポストバックがエンド ユーザーに大きなちらつきを引き起こすため、完全なポストバックを引き起こさないリピーター内に AutoPostBack RadioButton を配置する方法を見つける必要があります。

4

0 に答える 0