MVC表单提交回调

发布于 2024-12-24 18:37:06 字数 130 浏览 1 评论 0原文

我的母版页中有一个标题,我想在登录页面中启用它。我正在使用 document.onready 事件来完成此操作。但是,当我提交页面并且模型验证失败时,它不会显示标题。当 mvc 验证失败或重新加载页面时,是否有任何 javascript 被调用。

I have a header in my master page which i want to enable it in my login page. I am doing it using document.onready event. But when I submit the page and if the model validation fails, it doesn't show the header. Is there any javascript that gets called when the mvc validation fails or when the page gets reloaded.

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

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

发布评论

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

评论(1

紧拥背影 2024-12-31 18:37:06

您可以使用 pageLoad 事件。

function pageLoad() { 
    // Initialization code here, meant to run once. 
} 

这是一篇有关文档就绪和页面加载之间差异的文章。

http://encosia.com/document-ready-and -pageload-are-not-the-same/

你还可以在局部视图中附加一个事件,这里有一篇关于添加事件的帖子:
页面加载后执行的 JavaScript

There is a pageLoad event that you can use.

function pageLoad() { 
    // Initialization code here, meant to run once. 
} 

Here is an article about the differences between document ready and pageLoad.

http://encosia.com/document-ready-and-pageload-are-not-the-same/

You can also attach an event in the partial view, there is a post about adding events here:
Javascript that executes after page load

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