我正在尝试更新网页中的多个“更新”面板,我使用javascript运行后端代码来更新面板。我发现在准备就绪的文档中,仅运行了最后一个触发后端功能的javascript语句。
这是我的JavaScript代码。
$(document).ready(function () {
$("#ContentPlaceHolder1_BoxContent_Button2").click();
$("#ContentPlaceHolder1_BoxContent_Button3").click();
$("#ContentPlaceHolder1_BoxContent_Button1").click();
});
这是我的后端代码。
protected void LoadData(object sender, EventArgs e)
{
PanelHideShow.Visible = true;
Loading();
PanelHideShow.Visible = false;
//RegisterAsyncTask(new PageAsyncTask(() => Loading()));
}
protected void LoadData2(object sender, EventArgs e)
{
PanelHideShow.Visible = true;
Calculate3(
Util.CACHE_NAME__ELECTRICITY_CONSUMPTION
, "kWh"
, uiElectricityConsumptionUnit
, uiElectricityConsumption
, uiElectricityConsumptionYoY
, uiElectricityConsumptionUpOrDown
, "Electricity_YOY"
, companyID
);
PanelHideShow.Visible = false;
//RegisterAsyncTask(new PageAsyncTask(() => Loading()));
}
protected void LoadData3(object sender, EventArgs e)
{
PanelHideShow.Visible = true;
Calculate3(
Util.CACHE_NAME__TOTAL_GHG_EMISSIONS
, "tCO2e"
, uiGHGEmissionsYearlyUnit
, uiGHGEmissionsYearly
, uiGHGEmissionsYearlyYoY
, uiGHGEmissionsYearlyUpOrDown
, "GHG_YOY"
, companyID
);
PanelHideShow.Visible = false;
//RegisterAsyncTask(new PageAsyncTask(() => Loading()));
}
这是aspx。
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div style="display: none">
<asp:Button ID="BoxContent_Button1" runat="server" Text="Update box Panel" OnClick="LoadData" />
</div>
<asp:Panel ID="PanelHideShow" runat="server" Height="262px" Width="350px">
<IMG SRC="img/loading2.gif" style="opacity:0.4;filter:alpha(opacity=40);" WIDTH="350px" BORDER="0" ALT="">
</asp:Panel>
<div class="row">
<div class="col-lg-3">
<div class="ibox-content_v2" style="height: 150px;">
<div style="display: inline; height: 100px;">
<img src="images/ico_paper.png" width="45" height="45" style="margin-top: 10px; margin-right: 15px;" />
</div>
<div style="display: inline; height: 100px; float: right; max-width: 70%; min-width: 165px; width: 70%">
<span style="font-size: 13px; font-weight: 600; color: #888888">
<asp:HyperLink ID="uiBox1TitleLink" runat="server" Text="<%$ Resources:Resource,Total_Paper_Consumption %>" CssClass="TitleLink" /></span>
<br />
<asp:Label ID="uiBox1Value" runat="server" Style="font-size: 30px; font-weight: 600; color: #002467" />
<asp:Label ID="uiBox1Unit" runat="server" Style="font-size: 13px; font-weight: 600; color: #002467" />
<br />
<span style="float: right; padding-top: 3px;">
<asp:Label ID="Label8" runat="server" Text="<%$ Resources:Resource,YOY %>" CssClass="YOYLabel" />
<asp:Image ID="uiBox1UpOrDown" runat="server" Width="6" Height="9" Style="margin-right: 5px; margin-bottom: 4px;" ImageUrl="images/ico_arrow_xs_g_up.png" /><asp:Label ID="uiBox1Percentage" runat="server" Style="font-size: 13px; font-weight: 600;" Text="<%$ Resources:Resource,NA %>" /></span>
</div>
<div id="uiBox1TargetPanel" runat="server" onmouseover="document.getElementById('ContentPlaceHolder1_uiBox1Popup').style.visibility = 'visible';" onmouseout="document.getElementById('ContentPlaceHolder1_uiBox1Popup').style.visibility = 'hidden';">
<asp:Image ID="uiBox1TargetArrow" runat="server" Width="8" Height="14" CssClass="TargetArrow" ImageUrl="images/target_arrow.png" Visible="false" />
<div style="width: 100%; display: table;">
<div id="uiBox1TargetGreenLine" runat="server" style="height: 5px; width: 100%; background-color: #FF7373; display: table-cell;"></div>
<div id="uiBox1TargetRedLine" runat="server" style="height: 5px; width: 100%; background-color: #97B879; display: table-cell;"></div>
</div>
<div id="uiBox1Popup" runat="server" style="float: left; position: relative; top: -50px; visibility: hidden; width: 100%; height: 40px; text-align: center; border-width: 1px; border-style: solid; border-color: #D2D9E3; background-color: #F2F3F6; font-size: 13px; font-weight: 600; padding-top: 10px;">
<asp:Label ID="uiBox1TargetLabel" runat="server" />:
<asp:Image ID="uiBox1TargetUpOrDownImage" runat="server" Width="6" Height="9" Style="margin-right: 5px; margin-bottom: 4px;" ImageUrl="images/ico_arrow_xs_r_up.png" />
<asp:Label ID="uiBox1TargetValue" runat="server" />%
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div style="display: none">
<asp:Button ID="BoxContent_Button2" runat="server" Text="Update box Panel" OnClick="LoadData2" />
</div>
<div class="ibox-content_v2">
<div>
<img src="images/ico_electricity.png" width="30" height="30" style="margin-right: 15px;" />
<asp:Label ID="uiElectricityConsumption" runat="server" Visible="false" />
<asp:Label ID="uiElectricityConsumptionUnit" runat="server" Visible="false" />
<span style="font-size: 18px; font-weight: 600; color: #888888;">
<asp:Label ID="uiDashboard2Title" runat="server" Text="<%$ Resources:Resource,Electricity_Consumption %>" /></span>
<span style="float: right; padding-top: 3px;">
<asp:Label ID="uiElectricityConsumptionYoYLabel" runat="server" Text="<%$ Resources:Resource,YOY %>" CssClass="YOYLabel" />
<asp:Image ID="uiElectricityConsumptionUpOrDown" runat="server" Width="6" Height="9" Style="margin-right: 5px; margin-bottom: 4px;" /><asp:Label ID="uiElectricityConsumptionYoY" runat="server" Style="font-size: 13px; font-weight: 600;" /></span>
<asp:Label ID="uiDashboard2Label" runat="server" Text="<%$ Resources:Resource,Yearly %>" Visible="false" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div style="display: none">
<asp:Button ID="BoxContent_Button3" runat="server" Text="Update box Panel" OnClick="LoadData3" />
</div>
<div class="ibox-content_v2">
<img src="images/ico_greenhouse.png" width="30" height="30" style="margin-right: 15px;" />
<asp:Label ID="uiDashboard1Label" runat="server" Text="<%$ Resources:Resource,Yearly %>" Visible="false" />
<asp:Label ID="uiGHGEmissionsYearlyUnit" runat="server" Visible="false" />
<span style="font-size: 18px; font-weight: 600; color: #888888;">
<asp:Label ID="uiDashboard1Title" runat="server" Text="<%$ Resources:Resource,GHG_Emissions %>" /></span>
<span style="float: right; padding-top: 3px;">
<asp:Label ID="uiGHGEmissionsYearlyYoYLabel" runat="server" Text="<%$ Resources:Resource,YOY %>" CssClass="YOYLabel" />
<asp:Image ID="uiGHGEmissionsYearlyUpOrDown" runat="server" Width="6" Height="9" Style="margin-right: 5px; margin-bottom: 4px;" /><asp:Label ID="uiGHGEmissionsYearlyYoY" runat="server" Style="font-size: 13px; font-weight: 600;" /></span>
<asp:Label ID="uiGHGEmissionsYearly" runat="server" Visible="false" />
</div>
</ContentTemplate>
</asp:UpdatePanel>