Search

Atalasoft Knowledge Base

HOWTO: Using the DefaultAnnotations collection to create annotations using JavaScript (Legacy Web Controls)

Administrator
DotImage

Legacy Controls NOTICE

This article references our legacy Web Forms Web Viewing controls (WebImageViewer, WebAnnotationViewer, WebThumbnailViewer). It is preserved for archival purposes, but support strongly recommends using our modern HTML5 web controls: WebDocumentViewer, WebDocumentThumbnailer instead)

INFO: WebDocumentViewer Whitepaper - Getting Started With Web Viewing (11.1 Version)

Main Article Content

To use the DefaultAnnotations collection in conjunction with JavaScript, you will need to make sure that the annotations you are adding to the collection are added in the Page.OnInit event during the Page life cycle. This is necessary because the asynchronous JavaScript requests to create annotations are executed in the Init phase of the Page life cycle. Here is an example:

Code-Behind

// Code-behind:
// This needs to be called after InitializeComponent() in OnInit 
private void InitializeDefaultAnnotations() 
{ 
   RectangleData highlighter = new RectangleData(); 
   highlighter.Name = "Highlighter"; 
   highlighter.Outline = new AnnotationPen(Color.Transparent, 1); 
   highlighter.Fill = new AnnotationBrush(Color.FromArgb(128, Color.Yellow)); 

   WebAnnotationViewer1.Annotations.DefaultAnnotations.Add(highlighter); 
} 

JavaScript

// JavaScript: 
WebAnnotationViewer1.CreateAnnotation('RectangleData', 'Highlighter');

Original Article:
Q10172 - HOWTO: Using the DefaultAnnotations collection to create annotations using JavaScript (Legacy Web Controls)

Details
Last Modified: 2 Weeks Ago
Last Modified By: Administrator
Type: HOWTO
Article not rated yet.
Article has been viewed 10 times.
Options
Also In This Category