我对 web 开发相当陌生,我似乎无法显示加载 gif,而我正在执行导出后面的代码。
我的 onclick 事件位于 gridview 内的 Imagebutton 上。你能帮我么?在这里,我有 ImageButtons:
<HeaderTemplate>
<asp:ImageButton ID="btnExport" OnClick="btnExport_Click" runat="server" ImageUrl="~/Images/excel.gif" AlternateText="Export top records!"/>
<asp:ImageButton ID="btnExportRed" OnClick="btnExportRed_Click" runat="server" ImageUrl="~/Images/excel_red.gif" AlternateText="Export all records!"/>
</HeaderTemplate>
这是我背后的代码:
protected void btnExport_Click(object sender, EventArgs e)
{
try
{
LoadWaitImage();
[functional code]
UnloadWaitImage();
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
upnlMsg.Update();
UnloadWaitImage();
}
}
private void LoadWaitImage()
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "showMyImage", "hideLoading()", true);
}
private void UnloadWaitImage()
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "showMyImage", "hideLoading()", true);
}
和要触发的js:
function showLoading()
{
document.getElementById('lblMessage').value = "";
document.getElementById('ucMarketing_btnSearch').disabled = true;
document.getElementById('btnClearFilters').disabled = true;
document.getElementById('imgSaveToSegments').disabled = true;
document.getElementById('divLoadingImg2').style.display = "";
}
function hideLoading()
{
document.getElementById('ucMarketing_btnSearch').disabled = false;
document.getElementById('btnClearFilters').disabled = false;
document.getElementById('imgSaveToSegments').disabled = false;
document.getElementById('divLoadingImg2').style.display = "none";
}