views:

48

answers:

3

Hello fellows, I am using VSS 2005 & webforms with AJAX Control Toolkit. I am using Update panels for saving different parts of my form. Problem being I update the user with the status setting either a label or literal value.

This value is visible on the form untill the page is refreshed. Is there any way to display a message and fade it away after some seconds ? Would be a life saver for me =)

I am using VSS 2005 but I don't think a simple fade would require much intellisense with JQuery ?

A: 

You could use the UpdatePanelAnimation

http://www.asp.net/ajaxlibrary/act_UpdatePanelAnimation.ashx

Bruce Adams
+1  A: 

With a combination of the jQuery timers plugin and the jQuery fadeOut method, you might achieve what you want:

$(function() {
    $(this).oneTime(1000, function() {
        $('#book').fadeOut('slow', function() {
        // Animation complete.
        });
    });
});

This will call a function after the DOM is ready (first line). This function will call another function after one second (second line). This other function will fade out the item with id 'book'.

The DOM might not be 'finished' with updatepanels, I don't know. You could just make this a normal function (replace the first line with function removeMessage() { and the last line with }. Then in your updatePanel, add a call to this function. I haven't tested this myself, though.

Peter
Hi, what is the purpose for the .oneTime ? Can't we just specify the time in miliseconds on fadeOut ?
Popo
still can't figure this out yet.
Popo
The oneTime is part of the jQuery timers plugin, and the fadeOut is part of the jQuery UI. The time in milliseconds on the oneTime means the fadeOut will be called after 1000 milliseconds. If you pass an integer to the fadeOut (like `fadeOut(1000...)`, it will make the animation last 1000 milliseconds.
Peter
OK, I managed to get it working without the timer plug in but I still can't get it to work when label/div is outside the update panel. Any clue ?
Popo
A little off the top of my head, but I believe you have to register your ScriptManager. Something like `this.RegisterScriptManager(myScriptManager, myUpdatePanel)` where myScriptManager is the ScriptManager control you put on your page (or get it through `ScriptManager.GetCurrent(this.Page)`) and myUpdatePanel is your updatepanel. If this still doesn't work, let me know, I'll try it in a test project.
Peter
A: 

Hi,

I developed a simple light-weight control that you can just drag-n-drop and show "twitter style" flash messages.

http://dotnetkicks.com/aspnet/ASP_NET_SlidingMessage_Control

Please vote if you find it useful :)

Thanks

Dsyfa