如何停止 asp:UpdatePanel 异步调用调用页面加载

发布于 2024-08-12 07:42:02 字数 198 浏览 1 评论 0原文

使用: ASP.NET, C#, Javascript

我有一个页面,它在页面加载时调用 javascript 函数,该函数将多个事件绑定到元素。该页面还包含一个更新面板。当进行异步回发时,将再次调用页面加载函数并绑定事件。这在页面上产生了一些不良后果,我想知道是否有人可以帮助我。

预先感谢,

肖恩

Using:
ASP.NET,
C#,
Javascript

I have a page which calls a javascript function on pageload which binds several events to elements. The page also contains an update panel. When an asynchronous postback is made the pageload function is called again and the events are binded. This has some undesireable consequences on the page and i was wondering if anyone could help me out.

Thanks in advance,

Shawn

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

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

发布评论

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

评论(3

迷途知返 2024-08-19 07:42:02

该事件有一个参数告诉您它是否是部分加载:

function pageLoad(sender, args) {
    if (!args.get_isPartialLoad()) {
        // initial request
    }
    else {
        // after async post
    }
}

The event has an args that tells you whether its a partial load:

function pageLoad(sender, args) {
    if (!args.get_isPartialLoad()) {
        // initial request
    }
    else {
        // after async post
    }
}
秋叶绚丽 2024-08-19 07:42:02

对于遇到此问题的其他人来说,还有另一种解决方案。您可以将 Page_Load() 函数中的代码放入 if(!Page.IsPostBack) 语句中。这将防止任何更新面板在部分页面更新时调用 Page_Load() 事件。

希望这会有所帮助,

亚当

For anyone else who ever comes across this problem, there is another solution. You can place the code in the Page_Load() function into a if(!Page.IsPostBack) statement. This will prevent any update panels from calling Page_Load() events on a partial page update.

Hope this will help,

Adam

柳絮泡泡 2024-08-19 07:42:02

我找到了一个解决方法,但它有点混乱。

全局变量。

var isPageLoaded = true;

function pageLoad()
{

if(isPageLoaded){

//do stuff here
}
}

i found a workaround for this but its abit messy.

global variable.

var isPageLoaded = true;

function pageLoad()
{

if(isPageLoaded){

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