简体   繁体   English

网页加载后会触发哪个 c# 事件?

[英]which c# event will be fired after the webpage gets loaded?

I want to do some activity on backend means I want to run my code after the page gets loaded in the browser,which c# event gets fired when page loading completes?我想在后端做一些活动意味着我想在页面加载到浏览器后运行我的代码,当页面加载完成时会触发哪个 c# 事件? Or In which c# event should i write Code?或者我应该在哪个 c# 事件中编写代码?

Please help and suggest..请帮助和建议..

You can not run code on backend after the page get loaded in the browser.在浏览器中加载页面后,您无法在后端运行代码。

You can do some activity in the browser using javascript.您可以使用 javascript 在浏览器中进行一些活动。

Assuming you are looking at ASP.Net pages/forms (not MVC) then I recommend you take a look at the page lifecyle documentation: http://msdn.microsoft.com/en-us/library/ms178472.aspx假设您正在查看 ASP.Net 页面/表单(不是 MVC),那么我建议您查看页面生命周期文档: http://msdn.microsoft.com/en-us/library/ms178472.aspx

This documentation will talk you through these events:本文档将向您介绍这些事件:

页面生命周期 - 来自 MSDN

You cannot do any thing or run any code at server once output is sent to browser.将 output 发送到浏览器后,您将无法在服务器上执行任何操作或运行任何代码。 Use ajax on load to what you want to do.使用 ajax 加载到您想要执行的操作。 More specific requirement will help solving your issue.更具体的要求将有助于解决您的问题。 What are you trying to achieve.你想达到什么目的。 You need to understand basic structure how server and client do processing and interacts.您需要了解服务器和客户端如何处理和交互的基本结构。

After the page is loaded you can not do anything with the page in server side (c#), you should use javascript (ajax) to interact with the server after the page is loaded or use html5 sockets.页面加载后,您无法在服务器端(c#)对页面进行任何操作,您应该在页面加载后使用javascript(ajax)与服务器交互或使用html5 ZFFE33A3F6E35505FABA01D17FD07D64

But do you want to interact with the page that was loaded or just do some backend work, if it's some backend work that won't interact with the page you can use a Messaging Server (rabbitmq, wcf) to do stuffs....and if those stuff are needed to show on the page you can use cometjs to poll/push the results or html5 sockets to connect to the server and do some push stuff to the page......但是你想与加载的页面进行交互还是只是做一些后端工作,如果它是一些不会与页面交互的后端工作,你可以使用消息服务器(rabbitmq,wcf)来做一些事情......如果需要在页面上显示这些内容,您可以使用 cometjs 轮询/推送结果或 html5 sockets 连接到服务器并执行一些推送内容到页面......

.... ……

You can use the LoadComplete event.您可以使用 LoadComplete 事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM