1

我在页面上执行搜索时填充的 UpdatePanel 中有一个 GridView。当它被填充或页面改变时,它会执行一个淡入淡出动画。我还想执行其他更新 UpdatePanel 的操作,但我不希望这些操作执行这些淡入淡出动画。我在 ASP 论坛上找到的最接近的是:http ://forums.asp.net/p/1037038/1487096.aspx

该线程中提出的解决方案的问题是无法捕获更新和更新事件以进行动画处理。有任何想法吗?

谢谢,

缺口

4

2 回答 2

1

缺口,

是否可以考虑使用 JQuery 来制作动画?除了使用 UpdatePanelAnimationExtender 之外,您还可以更好地控制元素。

http://jquery.com/

http://docs.jquery.com/UI/Effects

于 2009-01-28T00:19:25.870 回答
1

只是想为这个答案添加一些代码,因为我设法使用来自不同地方的代码找到了一个很好的解决方案。:) (有些是粘贴的,有些是编辑过的;这个的最终版本没有经过测试,但你应该能够从中得到想法!)

var postbackElement; // Global to store the control that initiated the postback

// Using JQuery here
$(document).ready(function()
{
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);
});

function beginRequest(sender, args)
{
    postbackElement = args.get_postBackElement();

    // This method can be used to do animations in place of OnUpdating

    if(postbackElement.id == "YourControlId")
    {
      // or something like: if(id == "<%= YourControl.ClientID %>")

      // run your animation here
    }
}

function pageLoaded(sender, args)
{
    // This method can be used to do animations in place of OnUpdated

    // Also, the args variable holds a list of panels that are being updated;
    // I didn't use this though.

    // This condition is true on the first page load
    if (typeof(postbackElement) === "undefined")
    {
        return;
    }

    if(postbackElement.id == "YourControlId")
    {
      // run your animation here
    }
}
于 2009-02-03T21:39:16.557 回答