I use two UpdatePanel
tags, one has a Svg
inside and I need to refresh its content when a button is clicked, and the button is inside another UpdatePanel
. And I just realize my Page_Load
function in codebehind gets executed everytime I click the button. I set the property UpdateMode="Conditional"
already but not helping. Any idea why? Following is my code:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel runat="server" id="GlobalUpdatePanel" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="ButtonPP" eventname="Click" />
</Triggers>
<ContentTemplate>
<svg width ="1024" height = "540"></svg>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="ControlUpdatePanel" runat="server" Visible="True" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button id ="ButtonPP" runat="server" Text="Run PP" OnClick="ButtonPP_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Thanks in advance!
Since the Page_Load
function in code behind gets executed everytime the button is clicked, I'd guess you need to add if (!IsPostBack)
in there, something like this:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// code that's only executed at first load
}
}