页面加载后调用函数

页面加载后调用函数

本文介绍了页面加载后调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的页面中,用户可以下载文件.现在我想要的是用户可以单击一个按钮,然后将网站重定向到另一个页面,并且在加载页面后,下载应该自动开始.

我这样尝试过

In my page user can download a file. Now what i want is user can will click on a button and then site will be redirect to another page and after loading the page download should start automatically.

i tried like this

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load



       DownloadFile(filepath)


   End Sub



但是这里发生了什么,下载开始而没有显示该页面.
有人可以建议在页面加载后如何调用功能吗?页面完全加载后应该开始下载.

Sandip先生最好还是将精力集中在编程和问题上,而不是专注于哪个词.我已经看到您的回答如此之多,您的大多数答复中都有这样的愚蠢答案.您似乎只是为了增加分数而回答. 我把这些文字加了大写,这是我的主要问题. 1号在这里大喊.

Thanx Jaans,但我尝试了您的话题,但对我来说仍然是同样的问题.下载仅在前一页开始,而不在thanx页面上开始.您得到的是正确的百分比,我只想要thanx页面.能否请给我一些其他代码.



but what is happening here, download starts without showing the page.
Can anybody suggest HOW CAN I CALL FUNCTION AFTER PAGE LOAD? It should start downloading after page loaded fully.

Mr. sandip better u concentrate on programming and problems rather than which word seems like what. I have seen your so many answers most of your response are having some stupid answer like this. It seems like u r answering just to increase your score. I have put those text in caps mean that is my main issue. No1 is shouting here.

Thanx Jaans but I tried your thread but for me still its the same problem. Downloading starts on previous page only and its not coming on thanx page. What you got is cent percent correct i want thanx page only. Will you please give me some another code for this.

推荐答案

<head runat="server">
    <title>Your Thanks Page HTML design</title>


</head>
<body>
    <form id="form1" runat="server">
    <asp:Label ID="lblTime" runat="server"></asp:Label>
    </form>
</body>
<% DownloadFile(filepath)%>
</html>



注意:DownloadFile函数在文件后面的代码中定义,并且不应具有私有"访问修饰符.
这样,您应该在完全感谢页面的末尾下载文件.

请让我知道它是否对您有帮助.



Note: DownloadFile function is defined in code behind file and should not have a ''private'' access modifier.
This way you should get the file downloaded at the end of thanks page loaded fully.

Please let me know if it helps you.


hiren soni写道:
hiren soni wrote:

如何在调用后调用功能页面加载

HOW CAN I CALL FUNCTION AFTER PAGE LOAD


多数民众赞成在这里*喊* ...您不需要这样做!



Thats taken as *shouting* out here... you don''t need to do that!


hiren soni写道:
hiren soni wrote:

应该在页面完全加载后开始下载.

It should start downloading after page loaded fully.


您正在用Page_Load编写一段代码,并试图在完成代码后得到一些东西.
看起来您需要在页面渲染后下载.

只需查看页面生命周期,然后将文件下载方法放在render事件之后的render事件末尾即可.


You are writing a piece of code in Page_Load and trying to get something after finish of it.
It looks like you need the download after the Page rendering.

Just have a look at page life-cycle, and put your file download method at the end of render event of after the render event.



这篇关于页面加载后调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 15:23