用于检查页面何时完成加载的代码

发布于 2024-12-22 04:19:29 字数 205 浏览 4 评论 0原文

如何检查页面是否加载完成?如果有,我如何执行已在该页面后面的 C# 代码中创建的方法?

我想编排以下事件序列

  1. 完成加载页面
  2. 在页面中下载 gridview 作为 Excel 文件
  3. 调用此方法 download()
  4. 关闭浏览器

如何完成此操作?

How can I check whether the page has finished loading? When it has, how can I execute a method already created in the C# code behind for that page?

I would like to orchestrate the following sequence of events

  1. Finish Loading the page
  2. Download a gridview as an Excel file in the page
  3. Call this method download()
  4. Close the browser

How can I accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

A君 2024-12-29 04:19:29

链接可以回答您的问题吗?

示例用法(在您的 C# 代码中)

protected void Page_Load(object sender, EventArgs e)
{
      Page.LoadComplete +=new EventHandler(Page_LoadComplete);
}

void  Page_LoadComplete(object sender, EventArgs e)
{
    // call your download function
}

Does this link answer your question?

Example usage (in your C# code)

protected void Page_Load(object sender, EventArgs e)
{
      Page.LoadComplete +=new EventHandler(Page_LoadComplete);
}

void  Page_LoadComplete(object sender, EventArgs e)
{
    // call your download function
}
我的奇迹 2024-12-29 04:19:29

使用 JQuery 并进行回调以打开 xls 文件。

这里有一些详细的解决方案 POST 到服务器,接收PDF,使用 jQuery 交付给用户

基本上你可以挂接到

$(document).ready(function() {
  // do window.location or another one of the options to download the file.
});

Use JQuery and make a callback to open the xls file.

There is a few solutions detailed here POST to server, receive PDF, deliver to user w/ jQuery

Basically you can hook into the

$(document).ready(function() {
  // do window.location or another one of the options to download the file.
});
铃予 2024-12-29 04:19:29

你可以在 DOM javascript 中做到这一点:

window.onload = function() {
   download()
 }

You can do it in DOM javascript:

window.onload = function() {
   download()
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文