MVC 中的页面加载
在 ASP.NET 中,我通常使用 pageLoad()
JavaScript 函数,每次页面发送请求时都会执行该函数,即使使用 Ajax (UpdatePanel) 也是如此。
Razor 中有类似的东西吗?
我的意思是为每个 ajax 请求执行一个 JavaScript 函数,而不使用 OnSuccess 或 AjaxOptions 中类似的东西。
In ASP.NET I usually use pageLoad()
JavaScript function, that gets executed every time the page sends a request even with Ajax (UpdatePanel).
Is there anything like that in Razor?
I mean a JavaScript function to get executed for every ajax request without using OnSuccess or something like that in AjaxOptions
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望每次加载页面时都运行一个 javascript 函数,那么您需要在您希望其执行的每个页面的
top底部包含您想要的脚本,然后在其中您将拥有你想要运行的js。
如果您使用 jquery 那么我建议使用 $(document).ready()
Edit
或者,如果您希望每次加载页面时运行一些 csharp/vb 那么您需要在您的控制器并在其中放置必要的代码。
If you want a javascript function to run every time your page loads then you need to include the script you want at the
topbottom of every page you want it to execute onThen inside of that you'll have the js you want to run.
If you're using jquery then I suggest using $(document).ready()
Edit
Alternatively if you want some csharp/vb to run every time your page loads then you need to create a constructor in your controller and place the necessary code in there.