You can use the IsInPartialRendering property of the UpdatePanel class to determine if a specific panel caused the partial postback:
protected void Page_Render(object sender, EventArgs e)
{
if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) {
if (yourFirstUpdatePanel.IsInPartialRendering) {
// The first UpdatePanel caused the partial postback.
} else if (yourSecondUpdatePanel.IsInPartialRendering) {
// The second UpdatePanel caused the partial postback.
}
}
}
EDIT: It appears that IsInPartialRendering
is always false
before the Render
phase. Since you want that information during the Load
phase, it won't work as expected. See this bug.
There's a workaround documented here that consists in deriving your own class from UpdatePanel
to access its protected RequiresUpdate
property:
public class ExtendedUpdatePanel : UpdatePanel
{
public bool IsUpdating
{
get {
return RequiresUpdate;
}
}
}
After replacing asp:UpdatePanel
with ExtendedUpdatePanel
in your page markup, the code above becomes:
protected void Page_Load(object sender, EventArgs e)
{
if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) {
if (yourFirstUpdatePanel.IsUpdating) {
// The first UpdatePanel caused the partial postback.
} else if (yourSecondUpdatePanel.IsUpdating) {
// The second UpdatePanel caused the partial postback.
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…