【发布时间】:2015-02-25 18:12:47
【问题描述】:
在我的 ascx 页面中,我有两个面板,我试图在更新面板中更改这些面板。但是每次单击单选按钮时页面加载都会进行。这是我的代码
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel2" runat="server" >
<asp:RadioButtonList runat="server" ID="radioListAnswers" RepeatDirection="Horizontal" AutoPostBack="true" ClientIDMode="Static" onselectedindexchanged="radioListAnswers_SelectedIndexChanged">
</asp:RadioButtonList>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="radioListAnswers" EventName="SelectedIndexChanged"/>
</Triggers>
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Visible="false">
<div> Thanks</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
这是我的代码
void radioListAnswers_SelectedIndexChanged(object sender, EventArgs e)
{
panel2.Visible=false;
panel1.Visible=true;
}
点击页面重新加载的每个单选按钮。我们怎样才能克服这个问题。 提前感谢您的帮助。
【问题讨论】:
-
从您的单选按钮中删除
Autopostback="True"。 -
@CoderofCode 我删除了自动回发。但它不起作用...
标签: c# asp.net updatepanel