Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# UpdatePanel中的Repeater中的RadioButtonList导致完全回发_C#_Asp.net_Updatepanel_Repeater_Autopostback - Fatal编程技术网

C# UpdatePanel中的Repeater中的RadioButtonList导致完全回发

C# UpdatePanel中的Repeater中的RadioButtonList导致完全回发,c#,asp.net,updatepanel,repeater,autopostback,C#,Asp.net,Updatepanel,Repeater,Autopostback,我有一个RadioButtonList,其中AutoPostBack=true,在中继器中。整个中继器由更新面板包围。但是,RadioButtonList导致发生完全回发 我也尝试过其他场景,其中UpdatePanel也在repeater中,但仍然会遇到同样的问题 下面的代码显示了该问题 第一个单选按钮位于更新面板之外,应该会导致完全回发。这是正确的 第二个单选按钮位于其自己的更新面板中,应该会导致部分回发。这是正确的 第三个单选按钮位于更新面板内的中继器内。这将导致部分回发,但也会导致完全回发

我有一个RadioButtonList,其中AutoPostBack=true,在中继器中。整个中继器由更新面板包围。但是,RadioButtonList导致发生完全回发

我也尝试过其他场景,其中UpdatePanel也在repeater中,但仍然会遇到同样的问题

下面的代码显示了该问题

第一个单选按钮位于更新面板之外,应该会导致完全回发。这是正确的

第二个单选按钮位于其自己的更新面板中,应该会导致部分回发。这是正确的

第三个单选按钮位于更新面板内的中继器内。这将导致部分回发,但也会导致完全回发

<%@ 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>
第四个单选按钮位于中继器内的更新面板内。这也会导致临时回发,但会导致完全回发

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

受保护的无效页面加载(对象发送方、事件参数e)
{
如果(!IsPostBack)
{
rptTest1.DataSource=Enumerable.Range(1,1);
rptTest1.DataBind();
rptTest2.DataSource=Enumerable.Range(1,1);
rptTest2.DataBind();
}
}
日期1:
A.
B
C


日期2: A. B C

日期3: A. B C

日期4: A. B C


我需要找到一种方法,在中继器中安装一个自动回发单选按钮,该按钮不会导致完整的回发,因为页面本身很大,并且由此产生的回发会导致最终用户大幅闪烁。

我已经测试了您发布的代码,一切正常。RadioButtonList 2、3和4都会导致部分回发,而RadioButtonList 1会导致完全回发。代码中是否缺少某些内容?您使用的是什么visual studio?我只使用了2010进行了测试。因此,如果我在RadioButton上设置了clientMode=“AutoID”,那么一切都可以正常工作。我的猜测是,它在项目具有不同默认集的某些情况下工作。默认情况下,所有控件都只使用Inherit.2008中测试的。那你整理好了吗?