Friday, October 26, 2007

Ajax UpdatePanel (7) UpdatePanel API

API:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

<ContentTemplate>

<%= DateTime.Now %>

<asp:Button ID="Button2" runat="server" Text="Button" />

</ContentTemplate>

</asp:UpdatePanel>

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />



using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Demo2_API : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(this.Button1);

ScriptManager.GetCurrent(this).RegisterPostBackControl(this.Button2);

}

protected void Button1_Click(object sender, EventArgs e)

{

this.UpdatePanel1.Update();

}

}

In this code, both Button1 and Button2 will update UpdatePanel1, but Button2 will trigger a synchronous postback.

blog comments powered by Disqus