UpdatePanelAnimationExtender:单击某个按钮时没有动画

时间:2009-01-27 18:04:57

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

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

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

谢谢,

尼克

2 个答案:

答案 0 :(得分:1)

尼克,

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

http://jquery.com/

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

答案 1 :(得分: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
    }
}