<asp:Panel ID="Panel5" runat="server" >
</asp:Panel>
<asp:Panel ID="Panel6" runat="server" >
</asp:Panel>
<asp:Panel ID="Panel7" runat="server" >
</asp:Panel>
<asp:Button runat="server" ID="addButton" Text="Add More" OnClick="btnMore_click" AutoPostBack ="false" style="margin-left: 877px" Width="84px"/>
如上面的代码,每个按钮单击我有三个 asp 面板,通过 btnMore_click 函数可见一个面板。
protected void btnMore_click(object sender, EventArgs e)
{
int count = this.Controls;
if(count == 1)
{
medPanel5.Visible = true;
this.Controls++;
}
if (count == 2)
{
medPanel6.Visible = true;
this.Controls++;
}
if (count == 3)
{
medPanel7.Visible = true;
this.Controls++;
}
}
但目前,当我单击按钮一组可见 true 时。我没有任何问题。但我面临页面重新加载,每次我需要向下滚动以单击添加更多按钮。有没有办法在这里停止页面重新加载?