Search

Atalasoft Knowledge Base

INFO: WebImageViewer - JavaScript API Reference (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

Main Article Content

atalaWebImageViewer

Although this function is public, it is not intended for users to create WebImageViewers on the client side directly. The server side generated HTML is needed for this function to initialize.

Properties

Server Name JavaScript Syntax : Return value Description
ClientID ID() : string Gets the server control identifier generated by ASP.NET.
N/A Form() : object Gets the form object that the Web server control is on.
AntialiasDisplay getAntialiasDisplay() : int
setAntialiasDisplay(value : int)
Gets or sets the quality of the scaled image.

Expected input: AntialiasDisplayMode or int from 0-3, 0:None 1:ScaleToGray 2:ReductionOnly 3:Full
AutoZoom getAutoZoom() : int
setAutoZoom(value : int)
Gets or sets a value indicating how the image should be zoomed as the control is resized or the image size changes. This will override setZoom. For a one time zoom, see setZoomMode.

Expected input: AutoZoomMode or int from 0-5, 0:None 1:BestFit 2:BestFitShrinkOnly 3:FitToWidth 4:FitToHeight 5:FitToImage
BackColor getBackColor() : string
setBackColor(value : string)
Gets or sets the background color of the Web server control.

Expected input: string representing a hex value or exact color name: '#ACFF00'
BorderColor getBorderColor() : string
setBorderColor(value : string)
Gets or sets the border color of the Web server control.

Expected input: string representing a hex value or exact color name: '#ACFF00'
BorderStyle getBorderStyle() : string
setBorderStyle(value : string)
Gets or sets the border style used for this Web server control.

Expected input: string representing Style: '1px solid #FF9900'
BorderWidth getBorderWidth() : int
setBorderWidth(value : int)
Gets or sets the border width of the Web server control in pixels.
BrowserFormat getBrowserFormat() : int Gets the format of the images created for browser output.

Returns an int: 0:Jpeg 1:Png 2:Gif 3:Auto
CachePath getCachePath() : string Gets the file path used for the file cache as specified in the Web.config file.
Caption getCaption() : string
setCaption(value : string)
Gets or sets a string used for creating a caption under the Web server control. HTML syntax is allowed.

Note: This property is tied to a hidden input tag, so changing this value to HTML in JavaScript could cause problems if the page needs to PostBack.
Centered getCentered() : bool
setCentered(value : bool)
Gets or sets a value indicating if the image is centered when the image is smaller than the Web server control.
N/A getDisplayImageUrl() : string Gets a url that will return the current viewable portion of the image. Often used for printing the current area of the image.
Font getFont() : string
setFont(value : string)
Gets or sets the font name associated with the Web server control.

Expected input: string representing font name: 'Verdana'
ForeColor getForeColor() : string
setForeColor(value : string)
Gets or sets the foreground color (typically the color of the text) of the Web server control.

Expected input: string representing a hex value or exact color name: '#ACFF00'
N/A getFrameIndex() : int Gets the index value used to open the current image.

Note: If the image has been modified with a server side ApplyCommand, or has been opened from a method other than OpenUrl or a linked WebThumbnailViewer, this will always return 0.
Height getHeight() : string
setHeight
(value : string)
Gets or sets the CSS height style property of the server control.

Expected input: string representing style height: '320px'
ImageDisplayOrder getImageDisplayOrder() : int Gets the order that tiles are loaded.

Returns an int: 0:Sequential 1:VisibleFirst 2:OnDemand
Image.Size getImageSize() : atalaSize Gets the size, in pixels, of the current image.
N/A getImageUrl() : string Gets the currently loaded image url.
MouseTool getMouseToolLeft() : int
getMouseToolRight
() : int
setMouseTool(left: int, right: int)
Gets or sets the behavior of the mouse when interacting with the viewable area.

Expected input: MouseToolType or int from 0-7, 0:None 1:Center 2:Selection 3:ZoomIn 4:ZoomOut 5:ZoomArea 6:Pan 7:PassThrough
MouseTool.Cursor getMouseToolCursor() : int
setMouseToolCursor(value : int)
Gets or sets the cursor used with the mouse tool.

Expected input: MouseToolCursor or int from 0-8, 0:Auto 1:Arrow 2:Crosshair 3:Grab 4:Hand 5:Move 6:ZoomIn 7:ZoomOut 8:Custom
Note: Currently, Grab is a CSS Extension supported by Mozilla based browsers only.
MouseTool.CustomCursor getMouseToolCustomCursor() : string
setMouseToolCustomCursor(value : string)
Gets or sets a value that represents the custom CSS style used for the MouseTool.

Expected input: string representing Style: 'wait' or 'url(MyCursor.cur)'
Note: Url based CSS cursor styles may not work in all browsers.
PathToResources getPathToResources() : string Gets the virtual path to where the image, script, and cursor files are located.
N/A getReturnValue() : var Gets the return value populated by the last successful RemoteInvoke.
ImagePosition getScrollPosition() : atalaPoint
setScrollPosition(value : atalaPoint)
Gets or sets the upper left image position in relation to the upper left corner of the Web server control. Negative values are expected.

Expected input: atalaPoint
ScrollBarVisibility getScrollBarVisibility() : int Gets the visibility of the scrollbars.

Returns an int: 0:Dynamic 1:None 2:Always
Selection getSelection() : Selection Gets the Selection object of this Web server control.
TileSize getTileSize() : atalaSize Gets the height and width of the tiles in pixels.
TitleBar getTitleBar() : string
setTitleBar(value : string)
Gets or sets a string used for a creating a title bar above the Web server control. HTML syntax is allowed.

Note: This property is tied to a hidden input tag, so changing this value to HTML in JavaScript could cause problems if the page needs to PostBack.
ViewPortSize getViewPortSize() : atalaSize Gets the size of the viewable area, excluding scroll bars.
Visibility getVisibility() : string
setVisibility(value : string)
Gets or sets a value that indicates whether the Web server control is hidden or visible on the page.

Expected input: string that is either 'hidden', 'visible', or 'inherit'.
Note: 'inherit' will return VisibilityStyle.Visible on the server side.
Width getWidth() : string
setWidth(value : string)
Gets or sets the CSS width style property of the server control.

Expected input: string representing style width: '200px'
Zoom getZoom() : float
setZoom(value : float)
Gets or sets the zoom level of the image in this Web server control.
ZoomInOutPercentage getZoomInOutPercentage() : int
setZoomInOutPercentage(value : int)
Gets or sets the percentage used to increase or decrease the zoom level when the zoom MouseTools are used.

Events

Server Name JavaScript Syntax Description
N/A AntialiasDisplayChanged = function() Fires when the AntialiasDisplay property has changed.
N/A AutoZoomChanged = function() Fires when the AutoZoom property has changed.
N/A BackColorChanged = function() Fires when the BackColor property has changed.
N/A BorderColorChanged = function() Fires when the BorderColor property has changed.
N/A BorderStyleChanged = function() Fires when the BorderStyle property has changed.
N/A BorderWidthChanged = function() Fires when the BorderWidth property has changed.
N/A CaptionChanged = function() Fires when the Caption property has changed.
CenteredChanged CenteredChanged = function() Fires when the Centered property has changed.
N/A FontChanged = function() Fires when the Font property has changed.
N/A ForeColorChanged = function() Fires when the ForeColor property has changed.
ImageChanged ImageChanged = function() Fires when the Image has changed.
N/A ImageSizeChanged = function() Fires when the Image changes size.
N/A MouseToolChanged = function() Fires when the MouseTool property has changed.
RemoteInvoked RemoteInvoked = function() Fires when the RemoteInvoke function is called.
ImagePositionChanged ScrollPositionChanged = function() Fires when the ScrollPosition has changed
SelectionChanged SelectionChanged = function() Fires when the Selection has changed.
N/A SizeChanged = function() Fires when the Size property has changed.
N/A TitleBarChanged = function() Fires when the TitleBar property has changed.
N/A VisibilityChanged = function() Fires when the Visibility property has changed.
N/A ZoomChanged = function() Fires when the Zoom property has changed.
N/A ZoomInOutPercentageChanged = function() Fires when the ZoomInOutPercentage property has changed.

Mouse Events

Note: All of these events pertain to the underlying image only, and attempt to pass a ImageMouseEvent object to the function.
N/A Clicked = function(e) Fires when the image is clicked. Passes an ImageMouseEvent object.
N/A DoubleClicked = function(e) Fires when the image is double clicked. Passes an ImageMouseEvent object.
N/A MouseDown = function(e) Fires when a mouse button is pressed down on the image. Passes an ImageMouseEvent object.
N/A MouseDownLeft = function(e) Fires when the when the left mouse button is pressed down. Passes an ImageMouseEvent object.
N/A MouseDownRight = function(e) Fires when the when the right mouse button is pressed down. Passes an ImageMouseEvent object.
N/A MouseMove = function(e) Fires when the mouse cursor moves over the image. Passes an ImageMouseEvent object.
N/A MouseOut = function(e) Fires when the mouse cursor leaves the image area. Passes an ImageMouseEvent object.
N/A MouseOver = function(e) Fires when the mouse cursor enters the image area. Passes an ImageMouseEvent object.
N/A MouseUp = function(e) Fires when a mouse button is released on the image. Passes an ImageMouseEvent object.
N/A RightClicked = function(e) Fires when the image is right clicked. Passes an ImageMouseEvent object.

Key Events

Note: The control must have focus for these events to fire. You can programmatically set focus to this control by calling Focus(). These events also attempt to pass a ImageKeyEvent object to the function.
N/A KeyDown = function(e) Fires when a key is pressed down, if the control has focus. Passes an ImageKeyEvent object.
N/A KeyUp = function(e) Fires when a key is released, if the control has focus. Passes an ImageKeyEvent object.
N/A KeyPress = function(e) Fires when a key is pressed down, and then released, if the control has focus. Passes an ImageKeyEvent object.

Methods

Server Name JavaScript Syntax Description
N/A ClearImage() Clears the image from client side only, used to return to a blank state.
N/A Focus() Puts focus on the WebImageViewer, used to enable key events.
N/A Invalidate() Forces the WebImageViewer to re-position child objects.
OpenUrl OpenUrl(url: string)
OpenUrl(url: string, index: int)
Opens an image into the WebImageViewer control from a URL or virtual path, and frame index.

Note: This function is asynchronous. If any code needs to be executed after this call, it should be placed in the ImageChanged event handler.
N/A PauseRefresh() Pauses UI updates for this control until ResumeRefresh is called. Pauses and Refreshes are nestable. The update happens when an equal number of ResumeRefresh and PauseRefresh calls are made.
Print Print() Prints the current image using javascript client code.
Redo Redo() Re-does an undo.
Invoke RemoteInvoke(mthd : string)
RemoteInvoke(mthd : string, args : Array)
Remotely invokes a server side method with the array of arguments.

Note: This function is asynchronous. If any code needs to be executed after this call, it should be placed in the RemoteInvoked event handler.
N/A ResumeRefresh() Resumes paused UI updates for this control. Pauses and Refreshes are nestable. The update happens when an equal number of ResumeRefresh and PauseRefresh calls are made.
N/A ScrollBy(dx : int, dy : int) Scrolls the viewer by the given values.
N/A ScrollTo(x: int, y: int) Scrolls the viewer to the given coordinates.
N/A setZoomMode(value : int) Zoom the image once, according to the given AutoZoomMode.

Expected input: AutoZoomMode or int from 0-5, 0:None 1:BestFit 2:BestFitShrinkOnly 3:FitToWidth 4:FitToHeight 5:FitToImage
Undo Undo() Reverts the image back to the previously cached image.

Note: This function is limited to Image changes only. The number of available undos relies on the server side CacheLevels property of the control.
Update Update() Forces the current image to be cached and updates the viewable area.


ImageMouseEvent

This object is based on the browser's mouse event object. The following properties are in addition to the properties that are specified by each individual browser.

Usage:

JavaScript
/* You will need a WebImageViewer and a reference to ClientTools.js before this snippet.
 * This reference is automatically added to the page inline with the WebControls,
 * so placing this snippet below the WebImageViewer control will be sufficient.
 */
Atalasoft.Utils.InitClientScript(BindImageMouseEvents);
function BindImageMouseEvents(){
   WebImageViewer1.DoubleClicked = ImageMouseEventExample;
   WebImageViewer1.RightClicked = ImageMouseEventExample;
}

// This simple example alerts the user when the image is double or right clicked.
function ImageMouseEventExample(e){
   var mousePos = Atalasoft.Utils.getMousePosition(e);
   alert(e.name + ' event fired on the image at ' + mousePos.X + 'x' + mousePos.Y);
}

Server Name JavaScript Syntax : Return value Description
N/A name : string The name of the event that is being fired.
N/A type : string The browser's mouse event type that this event is based on. Ex: 'mouseover'.


ImageKeyEvent

This object is based on the browser's key event object. The following properties are in addition to the properties that are specified by each individual browser (unless otherwise specified).

Usage:

JavaScript
/* You will need a WebImageViewer and a reference to ClientTools.js before this snippet.
 * This reference is automatically added to the page inline with the WebControls,
 * so placing this snippet below the WebImageViewer control will be sufficient.
 */
Atalasoft.Utils.InitClientScript(BindImageKeyEvents);
function BindImageKeyEvents(){
   WebImageViewer1.KeyDown = ImageKeyEventExample;
   WebImageViewer1.Focus();
}

// This simple example alerts the user when a key is pressed down while thw WebImageViewer has focus.
function ImageKeyEventExample(e){
   alert('KeyCode: ' + e.keyCode + ' pressed down.');
}

Properties

Server Name JavaScript Syntax : Return value Description
N/A altKey : bool Returns true if the alt key is pressed in combination with this key event, false otherwise.
N/A ctrlKey : bool Returns true if the ctrl key is pressed in combination with this key event, false otherwise.
N/A keyCode : int The browser's specific key code for keyup or keydown typed events, returns ASCII code on keypress typed events.

Note: This property is populated by the browser, and may not be the same value across all browsers.
N/A shiftKey : bool Returns true if the shift key is pressed in combination with this key event, false otherwise.
N/A name : string The name of the event that is being fired.
N/A type : string The browser's key event type that this event is based on. Ex: 'keyup'.


Selection

The Selection object is internal to the atalaWebImageViewer object.

Properties

Server Name JavaScript Syntax : Return value Description
Animated getAnimated() : bool
setAnimated(value : bool)
Gets or sets a value that indicates whether the selection will animate or not.
AutoPostBack getAutoPostBack() : bool
setAutoPostBack(value : bool)
Gets or sets a value that indicates whether the selection will automatically post back when it has changed on the client side.
BackColor getBackColor() : string
setBackColor(value : string)
Gets or sets a string that represents the color behind the dashed line.
ForeColor getForeColor() : string
setForeColor(value : string)
Gets or sets a string that represents the color of the dashed line.
Height getHeight() : int
setHeight(value : int)
Gets or sets the height of the selection.
Movable getMovable() : bool
setMovable(value : bool)
Gets or sets a value that indicates whether the selection can be moved after it is drawn.
MultiColor getMultiColor() : bool
setMultiColor(value : bool)
Gets or sets a value indicating if the selection is a solid or dashed line.
Position getPosition() : atalaPoint
setPosition(value : atalaPoint)
Gets or sets the position of the selection.
Resizable getResizable() : bool
setResizable(value : bool)
Gets or sets a value that indicating whether the selection can resize after it is drawn.
ShowGrips getShowGrips() : bool
setShowGrips(value : bool)
Gets or sets a value that indicating whether the grips of the selection are visible.
ShowTooltip getShowTooltip() : bool
setShowTooltip
(value : bool)
Gets or sets a value that indicating whether the tooltip is drawn while the selection is drawn.
Size getSize() : atalaSize
setSize(value : atalaSize)
Gets or sets the size of the selection.
Visibility getVisibility() : bool
setVisibility
(value : string)

Gets or sets a value indicating if the selection is hidden or visible.

Width getWidth() : int
setWidth(value : int)
Gets or sets the width of the selection.

Events

Server Name JavaScript Syntax Description
N/A Changing = function Fires while the selection is being modified through mouse movement.
RubberBandChanged Changed = function Fires when the selection has finished being modified.

Original Article

Q10355 - INFO: WebImageViewer - JavaScript API Reference (Legacy Web Controls)

Last Update

2026-11-23 - TD - (Removed Copy Code links)

Details
Last Modified: 6 hours ago
Last Modified By: Tananda
Type: INFO
Article not rated yet.
Article has been viewed 325 times.
Options
Also In This Category