0

I have a RadioButtonList with AutoPostBack=true that is within a Repeater. The entire Repeater is surrounded by an Update Panel. However, the RadioButtonList is causing a full postback to occur.

I have tried other scenarios where the UpdatePanel is also within the repeater as well and still get the same issue.

The following code shows the issue.

The first Radio Button is outside of an Update Panel and should cause a full postback. This works correctly.

The second Radio Button is within its own Update Panel and should cause a partial postback. This works correctly.

The third Radio Button is within a Repeater that is within an Update Panel. This should cause a partial postback, however, it is causing a full postback.

The fourth Radio Button is within an Update Panel that is within a Repeater. This should also cause a prtial postback, however, it is causing a full postback.

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

I need to find a way of having an AutoPostBack RadioButton within a repeater that does NOT cause a full postback as the page itself is large and the resulting postback causes a large flicker to the end user.

4

0 回答 0