我也尝试了按钮和更新面板中的几乎所有设置,但 当我单击按钮时,它仍然刷新整个页面。
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="auto-style1" style="background-image: none; background-color: #C0C0C0;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Text="1" Width="100px"></asp:Label>
<asp:Button ID="Button2" runat="server"
OnClick="Button2_Click" Text="Button" Height="26px"
Width="56px" CausesValidation="False" />
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
下面是代码背后。单击按钮时,标签将添加1。
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
Label2.Text += "1";
}
}