【问题标题】:UpdatePanelAnimationExtender: No animation when certain button clickedUpdatePanelAnimationExtender:单击某个按钮时没有动画
【发布时间】:2009-01-27 18:04:56
【问题描述】:

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

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

谢谢,

尼克

【问题讨论】:

    标签: asp.net ajax asp.net-ajax ajaxcontroltoolkit


    【解决方案1】:

    尼克,

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

    http://jquery.com/

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

    【讨论】:

    • 是的,我们实际上已经在使用 JQuery。我希望它足够灵活,可以使用 AE 来完成!不过还是谢谢。
    【解决方案2】:

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

    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
        }
    }
    

    【讨论】:

    • add_beginRequest 和 add_pageLoaded 真的很有帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 2021-01-18
    相关资源
    最近更新 更多