asp.net 防止引发事件

发布于 2024-08-18 10:29:38 字数 168 浏览 2 评论 0原文

我有一个位于页面 (.aspx) 上的控件 (.ascx)。该控件内有一个 asp.net 更新面板,其中包含该控件的所有内容。当控件进行回发时,它会自动引发来自控件的所有事件以及来自其所在页面的所有事件。这导致了严重的性能问题。

有什么方法可以阻止引发驻留在控件所在页面上的事件吗?

谢谢

I have a control (.ascx) that sits on a page (.aspx). Within that control there's a asp.net update panel that encompasses everything for that control. When the control does a post back it automatically raises all the events from the control plus all the events from the page it sits on. This is causing significant performance problems.

Is there any way to stop the events from being raised that reside on the page that the control is sitting on?

Thanks

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

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

发布评论

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

评论(1

寄居人 2024-08-25 10:29:38

检查 ScriptManager.IsInAsyncPostBack 属性

这是示例代码:

protected void Page_Load(object sender, EventArgs e)
{
    if (Page.IsPostBack)
    {
        // get a reference to ScriptManager and check if we are in a partial postback
        if (ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)
        {
            // partial (asynchronous) postback occured
            // insert Ajax custom logic here
        }
        else
        {
            // regular full page postback occured
            // custom logic accordingly                
        }
    }
}

Check the ScriptManager.IsInAsyncPostBack Property.

Here is the sample code:

protected void Page_Load(object sender, EventArgs e)
{
    if (Page.IsPostBack)
    {
        // get a reference to ScriptManager and check if we are in a partial postback
        if (ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)
        {
            // partial (asynchronous) postback occured
            // insert Ajax custom logic here
        }
        else
        {
            // regular full page postback occured
            // custom logic accordingly                
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文