UpdateControls 1.2 - UpdateIndicatorPanel Control Addition

I've updated the UpdateControls suite of controls for ASP.NET AJAX to include a new UpdateIndicatorControl that is based on my MIX AJAX patterns talk, that provides some options for directing user's attention to what has changed in dynamic Ajax pages...

In my AJAX patterns talk at MIX, I discussed the concept of using subtle UI effects to direct user attention to what has changed on the page in response to an action. Specifically, I demonstrated an UpdateIndicator control that used smooth scrolls and highlights to enable an application to do this, and add a nice touch of polish.

I've implemented an UpdateIndicatorPanel control within my UpdateControls suite (plus some enhancements to the existing UpdateHistory control), which is now at version 1.2 and can be downloaded along with sources and samples. Prior to this, I had an AnimatedUpdatePanel that used to animate in new content over old content during a partial post-back. That control works well when all of its contents change. The UpdateIndicatorPanel is useful when only a portion of its surrounding UpdatePanel's content has logically changed. For example, say I have a repeater within an UpdatePanel. When an item is added to the data source, the entire repeater is updated, but you're likely to want to direct the user's attention to specifically the new row as opposed to the entire set of rows. This is where UpdateIndicatorPanel comes in.

Using the Control
The included sample page uses a Repeater to display a list of data items and a FormView to add data items into the DataSource. In order to incrementally update the repeater whenever an item is added, it is within an UpdatePanel.

First, I'll add the UpdateIndicatorPanel control to the ItemTemplate, and move the original contents of the template into the panel. Don't worry, the control is a no-op in terms of IDs (i.e. nesting content does not make IDs longer), and is also a no-op in terms of rendering for all items other than the one you want to direct user attention to using a smooth scroll and an optional highlight effect following that.

<asp:Repeater runat="server" id="itemsList" DataSourceID="itemsDataSource">
  <ItemTemplate>
    <nStuff:UpdateIndicatorPanel runat="server" id="updateIndicator">
      <!-- regular item content -->
    </nStuff:UpdateIndicatorPanel>
  </ItemTemplate>
</asp:Repeater>

Secondly, you'll want to call the ShowUpdate method of this control to direct the user to specific content that has been updated. In the sample, this happens everytime there is a post-back, and the last item in the Repeater is a newly inserted item.

protected override void OnPreRenderComplete(EventArgs e) {
    base.OnPreRenderComplete(e);
    if (!Page.IsPostBack) {
        return;
    }

    RepeaterItem lastItem = itemsList.Items[itemsList.Items.Count - 1];
    UpdateIndicator updateIndicator = (UpdateIndicator)lastItem.FindControl("updateIndicator");

    updateIndicator.ShowUpdate(/* addHighlight */ true);
}

The server control exposes properties you can use to specify a CSS class for the highlight that can be used to determine the highlight color, as well as duration properties that control the timespan over which the animation is performed. Remember a tip I mentioned when introducing AnimatedUpdatePanel - find a duration that works well for demo, then half it for actual use, so you minimize the annoyance factor.

Behind the Scenes
The UpdateIndicatorPanel emits an instance of a client-side UpdateIndicator script behavior that is attached to the <div> rendered around the item content. Once the updated repeater content is displayed, the script behavior is instantiated, and during its initialization it creates a scroll effect. Once the scroll effect plays through, the behavior creates a highlight effect, and plays that if a highlight was added in addition to the basic scrolling gesture. The animation framework was pulled in from Script#, and all the client-side script was also written in Script# (I'll be releasing a Script# build soon that is targeted specifically at Microsoft ASP.NET AJAX).

Some Philosophy
Generally AJAX applications have a bad rap in that they are poor in providing feedback about what has changed. Certainly this can be a challenge. However, I see both AJAX and other rich client apps such as those written using Silverlight have the opportunity to be able to do a better job than traditional post-back-based pages, simply because the browser doesn't do its default thing. Specifically, since the entire page is not refreshed, and that leaves a sort of clean slate, where the application can do something more meaningful that is specifically tuned to the application scenario at hand.

I am interested in hearing about other mechanisms people have thought about or used to communicate how and what portions of their dynamic pages have changed, as well as other things that UpdateIndicatorPanel could offer besides scrolling and highlighting.

Posted on Wednesday, 5/16/2007 @ 12:50 PM | #Projects


Comments

24 comments have been posted.

Kori Francis

Posted on 5/16/2007 @ 1:45 PM
Nikhil - is there a link to the new code?

Nikhil Kothari

Posted on 5/16/2007 @ 4:18 PM
Doh... forgot to add the link ... I've updated the post now...

Brian Brown

Posted on 5/16/2007 @ 7:15 PM
The 'UpdateControlsScript' project seems to be missing from the download.

Nikhil Kothari

Posted on 5/16/2007 @ 9:36 PM
The UpdateControlsScript was intentionally not part of the release ... I just forgot to update the solution to remove the project. It is basically the script# project that builds the scripts included in the UpdateControls project, and depends on the unreleased version of the script# compiler. Since the generated scripts are included, you should be able to build/run the samples and use the controls.

George Kapsambelis

Posted on 5/17/2007 @ 8:29 AM
Nikhil - I'm confused about the UpdateHistory control. Is this the same one that is distributed with the recent May ASP.NET Futures release?

Nikhil Kothari

Posted on 5/17/2007 @ 8:54 AM
No this UpdateHistory isn't the same as the one in the Futures release, in that this only has a server programming model. However, both this and the futures one are based on the script# version I released way back, that does have both a client and server programming model. Functionally these are trying to address a similar problem obviously...

Mark Hildreth

Posted on 5/17/2007 @ 9:27 AM
"I'll be releasing a Script# build soon that is targeted specifically at Microsoft ASP.NET AJAX"

This is terriffic news. I've been anxious to get to work on some extender controls, but writing all the script is really tedious. Being able to just write out simple classes that can translate over will be a tremendous help!

Jeff

Posted on 5/17/2007 @ 11:32 AM
This would be a very useful demo if we could see the original scripts, non-obfuscated.

Nikhil Kothari

Posted on 5/17/2007 @ 5:42 PM
The general pattern with ASP.NET AJAX controls is that they come with both debug and release scripts. This suite of controls is no different. If you set the ScriptMode on ScriptManager to Debug, you'll see debug scripts being used which aren't obfuscated/minimized. Alternatively if you open up the solution, you'll see UpdateControls.debug.js in addition to UpdateControls.js - the former is what you're looking for.

Remy Blaettler

Posted on 5/20/2007 @ 8:53 AM
Asome stuff. What would be cool, is if we could use this functionality somehow to highlight a new row in a GridView. Since this seems to be the most common approach to display lists and stuff. I know I could achive the same effect with the repeater control, just saying it would be cool. Maybe if you add a property with an element id to use as the indicator?

Nikhil Kothari

Posted on 5/20/2007 @ 10:28 PM
Remy, I fully agree with your grid scenario in terms of it being important, and wanted to do it, but decided in favor of shipping what I had for now.

The highlighting functionality works by placing a highlight panel behind the content rather than by touching the background of the updated content, as its more reliable, doesn't mess with actual content's CSS etc. This is not possible to do with a table, at least not as easily as simply pointing a row to highlight. Still need to think exactly how to support it...

Remy Blaettler

Posted on 5/21/2007 @ 5:29 AM
Sure, ship early and often as they say :-)
I'm actually just writing a little task list, so decided to go with the repeater instead of the grid. I guess you could control a row's background color without messing too much with the existing CSS.
Any plans on merging your library with the Ajax Toolkit from Codeplex? I saw that both include an Updatepanel that supports animation.

Nikhil Kothari

Posted on 5/21/2007 @ 10:37 PM
I got email from one of the folks trying to build the product about an error along the lines of cryptographic error... this is because the downloadable source project does not contain the signing key. If you want to build a custom version, you'll need to generate a private key using sn.exe ... that way the original assembly can be identified.

Remy, the animation model for AnimatedUpdatePanel is different from the one in the toolkit. The control I have is designed to animate new content in over the old content, as opposed to animate in the new content after removing the old content - subtle difference, but sometimes thats the effect you want. No plans right now to merge this project into the toolkit.

Mark Grocki

Posted on 5/23/2007 @ 8:36 AM
Nikhil, have you looked into the issue posted about in your 1.1 entry, the one where IE is not preserving Ajax history when posting to a new page? Firefox seems to work, but IE7 (haven't tested IE6) isn't. This is a great little project otherwise!

pkacha

Posted on 5/24/2007 @ 6:50 AM
I have gone through your article on Back Button Support for Atlas UpdatePanels, i want to use only the back button functionality in ajax application without using update panels, is there any way i can implemet the same in my project. I have downloaded the HistoryDemo.zip, but i was not able to figure how to use the same. Can you please help me on the same.

Nikhil Kothari

Posted on 5/24/2007 @ 2:30 PM
Mark: Haven't had a chance to, but its on my list of things...

pkacha: The back button functionality in this package is tied to server controls... its not specifically tied to update panels, but update panels are the way to incrementally update a page without a post-back, which is a prerequisite to even have history behavior. If you're looking for just a client-script implementation, you can either look at the UpdateControls.debug.js source, or you can look at my Script# project, which was the starting point for this functionality.

Max

Posted on 5/26/2007 @ 8:40 AM
I have a few bug reports on the UpdateAction control which I hope might be useful:

- In ShowMessage, the message string should be escaped, i.e. .ShowMessage("string contains 'a quote") currently causes it to crash

- If you put an UpdateAction control inside an UpdatePanel, you get an incorrect error message: "An UpdateHistory control should not be placed within an UpdatePanel"

- The control prevents .NET's own Control.Focus() from working.

- I found I could only call updateAction.SetFocus() once per page lifetime. Calling it a second time caused 'Object doesn't support property or method' on window.WebForm_AutoFocus(options.focusID);

Hope some of that's useful & thanks for the HistoryControl, saved my bacon.

Remy Blaettler

Posted on 5/29/2007 @ 10:27 AM
Seems like you get plenty of responses here :-)
And I have one more wish too:
Since you have the highlight effect if something is added to the list, do you think it would be possible to do the opposite if something is removed? Kinda like in Highrise where the item fades out. If implemented it with two Animation Extender, but its cumbersome and creates massive pages.

Zak

Posted on 7/31/2007 @ 12:06 PM
I'd really like to see the ability to disable the "scroll to" part of the UpdateIndicatorPanel. I tried using this on a comment submission form on a site and with it popping up to the stop and then moving down it looks like a full PostBack anyway. Just the highlight is enough in some cases.

Bryan

Posted on 8/15/2007 @ 11:44 PM
First of all I used your UpdateHistory control in UpdateControls suite 1.2 in my website. But my website performed on three load balancing servers. When I opened The page contained UpdateHistory control with ie browser, it always appears the message "loading page" in the status bar. The page doesn't seem to load completely. So I can't enter text to my editable iframe. The UpdateHistory control didn't run at load balancing web servers.

Swami

Posted on 9/3/2007 @ 12:55 PM
Is there a way to disable the scrolling and just have the highlighting? In my datalist, the most recent item appears on the top anyway, so it's quite visible after insertion and the scroll functionality is not needed--in fact it's distracting.

Otherwise, great control!

Nikhil Kothari

Posted on 9/8/2007 @ 12:23 PM
Zak/Swami - there is a boolean property to selectively disable the scrolling, if I remember.

Remy - Highlight the item being removed is tricky but certainly possible. For example if you're deleting a row in a table, you need to actually update the whole table, but you don't want to highlight the table. The updated table doesn't contain the row that is being deleted - its gone by definition, so there is again nothing to highlight. You pretty much need to do the highlight before in anticipation of the delete, once the postback is sent. Very doable - but not with the UpdateHighlight as-is. Good idea though... something to add to the list. But hopefully the description above should give some idea of doing this before on your end :-)

Abel Braaksma

Posted on 4/22/2008 @ 1:44 AM
Just a small comment: the previous page (about UpdateControls11.aspx (I think a link is not allowed in a post? I got an error saying "your post has unallowed words")) does not contain a forward link to this update. All earlier updates do and since you enter this scene on the first beta of UpdateControls when you hit it from Google, I think it is wise to somehow update all previous post to link directly to the newest version.

Perhaps you could create a web page (not a blog post) that always contains the latest version, like a project page or something?

Btw: thanks for a great control. I'll try it with .NET 3.5 and I'll come back when there're any issues with it.

jignesh

Posted on 4/24/2008 @ 12:54 AM
Hello,nikhil.I use your animatedUpdatePanel Control in my project.I used it for Cross fade Effects.I have a Timer control in updatePapanel and on timer_Tick event i changed Image url.So image is changed on every Timer_Tick event.I want cross fade effects so i put image in Animatedupdate Panel.All things go well i check it in IE and FF.But when i close my browser i got an error like
Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'Array' cannot be converted to type 'Boolean'.
Parameter name: condition

I Don't understand what the reason behind it.
So pls help me.
thanks
Jignesh Prajapati
Web Developer
Grinfosys
India
Jignesh6990@yahoo.co.in
The discussion on this post has been closed. Please use my contact form to provide comments.