I have an update panel with postbacktriggers
and the label that I plan to update is in the navbar, which is not included in the UpdatePanel where the triggers are located. Below is the structure of that code:
<asp:Label ID="totalScorecardsLabel" runat="server"></asp:Label>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:PostBackTrigger ControlID="btnGenerateScorecard" />
<asp:PostBackTrigger ControlID="exportPDFbtn" />
<asp:PostBackTrigger ControlID="generateNewBtn" />
</Triggers>
<ContentTemplate>
divs.. etc
</ContentTemplate>
</UpdatePanel>
On the other hand, I have a click event for exportPDFbtn
that adds entries to a list, therefore incrementing the list size.
int totalScorecards = loadTest1.Count + loadTest2.Count + loadTest3.Count + loadTest4.Count;
totalScorecardsLabel.Text = totalScorecards.ToString();
The totalScorecards
Label is outside the UpdatePanel. I've set it to 0
on Page_Load if (!IsPostBack)
.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
init();//initialize all lists etc
int totalScorecards = 0;
totalScorecardsLabel.Text = totalScorecards.ToString();
}
}
After clicking the exportPDFbtn
, I expect a increment change in the label. After that I plan to click the generateNewScorecardbtn
, and expect the totalScorecards number to carry on postbacks.
But the problem is that the label is still on 0
even though elements are successfully added to the lists in the exportPDF
clickEvent (used breakpoints to discover if it really adds to the lists). I also use Server.Transfer("Scorecards.aspx")
for the generateNewScorecardbtn
.
Any help would be appreciated. Thanks!
Put it into another Update Pannel and use Update() method
https://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.update(v=vs.110).aspx