2015-04-13 5 views
0

У меня есть код ниже, который будет создавать всплывающий файл aspose excel. Мне нужен блок сценариев для выполнения из javascript сразу после загрузки. Регистровый архив не запускается в приведенном ниже коде.Добавить блок сценария после сохранения книги в C#

что не так в этом?

workbook.Save(HttpContext.Current.Response, "Template.xls", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003)); 


Page.RegisterStartupScript("alert", "<script>parent.downloadcomplete()</script>"); 

ответ

0

Используйте экземпляр ClientScriptManager.

workbook.Save(HttpContext.Current.Response, "Template.xls", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003)); 
// Page.RegisterStartupScript("alert", "<script>parent.downloadcomplete()</script>"); 

ClientScriptManager cScript = Page.ClientScript; 
if (!cScript.IsStartupScriptRegistered(this.GetType(), "alert")) 
{ 
    // Register if not done already 
    string javascriptCode = "<script type='text/javascript'> alert('Download complete'); </script>"; 

    cScript.RegisterStartupScript(this.GetType(), "alert", javascriptCode); 
}