Home : WebForms Web Viewing Controls : When to use client side scripting to repaint annotations in the WebAnnotationViewer.
Q10349 - HOWTO: When to use client side scripting to repaint annotations in the WebAnnotationViewer.

When making server side changes to annotations in a WebAnnotationViewer, occasionally you may find a circumstance where the rendered image version of an annotation does not update. This is a side effect of the optimization done to transmit annotation changes as efficiently as possible between the client and server. There is a very simple step you need to take to get your updated annotation image.

Certain changes made inside a RemoteInvoke will not flag the client side code to request an image update. If the annotation stays the same size/dimensions and you've only changed properties that would have a visual change, rotating 180 degrees, or changing a border color are a few examples that may cause this. This is because the way annotations are updated in the server side, the viewer is not explicitly told what has changed; it is only given the new annotations. It optimizes as much as possible, avoiding updating images for annotations that do not appear to have changed. In the instances where something has changed sizes or has updated content it knows to repaint. However, in those earlier examples, it just looks like the annotations have stayed in place.

When you've made a change that falls under this category, or you are seeing this behavior, calling Repaint() in your client-side code on those updated annotations will cause them to request updated images.

Assuming you've named your WebAnnotationViewer WAV, you can get the current layer's annotations with WAV.getCurrentLayer().getAnnotations() which will return an array of all the atalaAnnotation objects. Then just use the array index to call Repaint() on the annotation that requires it. In the event you want to update all the annotations on the current layer you can use a little bit of jQuery to make it very simple. Just be aware that this is a complex operation and calling it unnecessarily will add overhead to your application and strain on your server.

If you're using JQuery in your application, it's as easy as:

$.each(WAV.getCurrentLayer().getAnnotations(), function(index, anno) { anno.Repaint(); });

If you're not using JQuery:

var annos = WAV.getCurrentLayer().getAnnotations();
for (var i = 0; i < annos.length; i++) {

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?


Tell us why you rated the content this way. (optional)
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2019. InstantASP Ltd. All Rights Reserved