Control

The base class of all controls.

Remarks

Has methods for converting controls into Dom elements, and for handling events from the Dom.

Properties

ID_animatorsA SitedList of animators.
ID_controlIdThe ID this control is known in the nearest binding container parent.
ID_eventMask(Advanced) A comma-separated list of peer events this control should receive.
ID_isBindingContainer(Advanced) Force this control to act as a binding container.
ID_isPeerless(Advanced) Set this to true to prevent this control from generating a peer element in the rendered HTML.
ID_submittersA SitedList of submitters.
ID_tagNameOverrides the default HTML tag name used for this control.
ID_visibleTrue if this control is visible, false if it is hidden.

Events

ID_mouseDownEvent handler called when a mouse button is pressed down.
ID_mouseMoveEvent handler called when the mouse is moved.
ID_mouseOutEvent handler called when a leaves a control.
ID_mouseOverEvent handler called when a mouse moves over a control.
ID_mouseUpEvent handler called when a mouse button is released.

Methods

acceptsDropCalled to determine if this control will accept a drop.
addBindingAdds a databinding between a property on this object and a binding path.
addBindingExExtended entry point for adding a binding.
addCalculatedBindingAdds a calculated binding for a property.
addClassNameAdds a CSS class to this controls "class" attribute
addEventHandler (inherited from SitedObject)Adds a delegate to be called when the specified eventId occurs on this object.
animateExAnimates a property to a value.
blurTells this control's peer to relinquish keyboard focus.
bubbleBubbles a message up the control hierarchy - calls onBubbleEvent on this control and each of its parents.
captureMouseRegister a control to receive mouse move/up events
constructUsed to initialize a markup control.
equals (inherited from SitedObject)Tests if two objects are equal.
fireEventHandler (inherited from SitedObject)Invokes any user event handlers registered for a particular event using SitedObject.addEventHandler().
focusTells this control's peer to request keyboard focus.
getBindingContainerGets this object's nearest enclosing binding container.
getBindingStatus (inherited from SitedObject)Provides debugging information on bindings for this object.
getEventMaskGets an object indicating which peer events this control is interested in.
getParentGets the parent Control of this control.
getPathValue (inherited from SitedObject)Traverses a binding path and returns the value at the end of it.
getPeerGets the peer DOM element associated with this control.
getPeerForParentGets the peer element of this control that the parent control should use in DOM manipulations.
getPropertyInfo (inherited from SitedObject)Gets information on a property.
getResourceGiven the ID of a resource, returns the resource's value.
getSite (inherited from SitedObject)Gets this object's site.
getTagNameGets the HTML tag name this control will use for its peer element.
getValue(Override) Gets a property, style or attribute.
getViewState Retrieve any viewstate that has been saved for this control in a previous session.
getViewStateId Get a unique and consistent viewstateId for this control.
invalidateLayoutTells the layout system to redo layout.
onBubbleEventCalled to handle a bubbled event.
onDragEventCalled to handle a drag drop event..
onFirstRenderCalled the first time a control is rendered.
onPeerCreatedCalled when a peer is created.
onPeerEventCalled to dispatch low level events that arise in the Dom.
onSetValue (inherited from SitedObject)Called by SitedObject.setValue() when a property value is set on this object.
onSited (inherited from SitedObject)Called when this object is sited.
onSitedRootCalled when a control is added to the main control tree.
onUnsited (inherited from SitedObject)Called when this object is about to lose its site.
onUnsitedRootCalled when a control is removed from the main control tree.
onValueSited (inherited from SitedObject)Called when an object is sited within this object.
onValueUnsited (inherited from SitedObject)Called when an object is about to be unsited in this.
onViewStateChanged Overridable. Controls implement this method to update their viewstate.
reflectOnBoundValueGets runtime reflection information on an underlying bound object.
removeClassNameRemoves a CSS class from this controls "class" attribute
removeEventHandler (inherited from SitedObject)Remove an existing delegate from the list of delegates for the specified event.
renderPlaces the Html representation of this control into the htmlBuilder.
renderAttributesCalled by Control.render() to render attributes for this control.
renderChildrenPlaces the Html markup for all the Control inside this control into the htmlBuilder.
setBoundsConvenience method to set the left/top/width/height of an element.
setInitialValues (inherited from SitedObject)Sets multiple property values on an object (during initialization only)
setPathValue (inherited from SitedObject)Traverses a binding path and sets the value at the end of it.
setValue(Override) Sets a property, style or attribute.
setViewState Save viewstate that should persist across sessions.
startAnimatorStarts an animation.
startDragDropStart a drag drop operation.
stopAnimatorStops an animation.
toString (inherited from SitedObject)Returns a string representation of this object.

Control acceptsDrop method

Called to determine if this control will accept a drop.

JavaScript

var boolVal = control.acceptsDrop(dragEventArgs)

Remarks

The control must have the property isDropTarget set to true to receive this message.

Returns

true if the drop is acceptable, false otherwise.

Overriden In

Control addBinding method

Adds a databinding between a property on this object and a binding path.

JavaScript

control.addBinding(propertyId,bindingPath)

Remarks

propertyId is the ID of the property you are binding against. bindingPath is an array of binding path elements. SitedObject.getPathValue() for a description of bindingPath.

Example

Here's how to create a LabelControl and bind its text property:

var label = new LabelControl();
label.addBinding(ID_text, ['../', ID_data, ID_people, 0, ID_firstName]);

Control addBindingEx method

Extended entry point for adding a binding.

JavaScript

control.addBindingEx(property,bindingPath,convert,convertBack,instant,defaultText)

Remarks

Allows you to specify converters, instant and default value on a binding.

Control addCalculatedBinding method

Adds a calculated binding for a property.

JavaScript

control.addCalculatedBinding(propertyId,bindingPaths,calculationFunction)

Remarks

Adds a calculated binidng on the property propertyId, with the dependencies bindingPaths, and the function calculationFunction. This will create a CalculatedBinding, which is a SitedObject that recalculates the value when updates occur.

Control addClassName method

Adds a CSS class to this controls "class" attribute

JavaScript

control.addClassName(className)

Control animateEx method

Animates a property to a value.

JavaScript

control.animateEx(duration,propertyId,toValue,units,onComplete,onCancel)

Remarks

This method creates an on-the-fly animation to animate a property. duration is a time in millis. propertyId specifies the property to animate, and toValue is the destination value. Units is a string specifying the CSS units for the animation (or null). onComplete and onCancel are delegates that are invoked when the animation is completed or cancelled respectively.

Example

Here's how to animate the CSS width of a control to 60 pixels over half a second:

control.animateEx(500, "$width", 60, "px");

Control blur method

Tells this control's peer to relinquish keyboard focus.

JavaScript

control.blur()

Control bubble method

Bubbles a message up the control hierarchy - calls onBubbleEvent on this control and each of its parents.

JavaScript

control.bubble(evtId,optionalEventArgs)

Remarks

This calls onBubbleEvent() on this control and each of its parents in turn, until it reaches a control whose onBubbleEvent returns false.

Example

This bubbles an ID_selectItem event up the control hierarchy:

this.bubble(ID_selectItem);

When ListControl receives a ID_selectItem bubbled event, it looks at which child generated the event and selects the appropriate item associated with that child. Using bubbled events in this way means that the items within the list don't have to "know about" the containing ListControl.

See Also

Control captureMouse method

Register a control to receive mouse move/up events

JavaScript

control.captureMouse()

Remarks

On a mouse down event, controls can call control.captureMouse() to specify that the control should receive all further mouse events until the mouse button is released. At the mouseUp event at the end of the interaction, the mouse capture will be released.

Control construct method

Used to initialize a markup control.

JavaScript

control.construct()

Remarks

Controls that are defined via subclassing in markup are instantiated by first executing their constructor, then calling the construct() method on them. This method is used to initialize the control's defaults. Just like a constructor, any base class implementations of construct() are called first (in superclass-to-subclass order), before construct() is called on the current class.

Note that optional arguments are passed in to the construct method, representing any #param values and Placeholder controls referenced within within the control's defaults. This is done to initialize the control's defaults in an efficient way.

For most controls, this method is generated by the compiler. A no-op method is provided at the root.

Control focus method

Tells this control's peer to request keyboard focus.

JavaScript

control.focus()

Control getBindingContainer method

Gets this object's nearest enclosing binding container.

JavaScript

var aControl = control.getBindingContainer()

Remarks

This recursively searches up the hierarchy until it hits an ancestor that has the property ID_isBindingContainer set to true.

Returns

A Control whose ID_isBindingContainer property is true, or null if there is no binging container.

Control getEventMask method

Gets an object indicating which peer events this control is interested in.

JavaScript

var obj = control.getEventMask()

Remarks

This method inspects the event handlers registered with the control, and parses the Control.ID_eventMask property, and returns an associative array containing the eventIds of all the events the control wishes to receive.

For each event the control wishes to receive, the associative map has an entry whose key is the event ID and whose value is true.

For example, if the user registers for click events, then getEventMask() returns an object for which obj[ID_click] = true.

Returns

A JavaScript object

Overriden In

Control getParent method

Gets the parent Control of this control.

JavaScript

var aControl = control.getParent()

Remarks

Returns null if this object is note added to a control hierarchy, or if it is a AppControl.

Note that this differs from the controls "site" (see SitedObject.getSite()). A control's site is a SitedList, which in turn sited as the "childControls" property of a control. In otherwords, calling control.getParent() is equivalent to calling control.getSite().getSite().

Returns

The parent control, or null if this control is a root control.

Control getPeer method

Gets the peer DOM element associated with this control.

JavaScript

var element = control.getPeer()

Remarks

This will return null if the control is peerless or has not yet been rendered for the first time.

Returns

An HTMLElement, or null if no DOM element is available.

Control getPeerForParent method

Gets the peer element of this control that the parent control should use in DOM manipulations.

JavaScript

var element = control.getPeerForParent()

Remarks

Container controls always call this method to determine which element a child control is using.

The default implementation simply returns this.getPeer().

A few controls may additional hidden HTML elements above their peer in the DOM - if a control does this, it should override getPeerForParent to return the outermost element it added to the DOM, so that any DOM manipulations by the parent control (insertChild, appendChild etc.) continue to work.

Returns

An HTMLElement, or null.

See Also

Control getResource method

Given the ID of a resource, returns the resource's value.

JavaScript

control.getResource(resourceId)

Remarks

This takes a resource Id, and returns the value of the resource. Currently, only string resources are supported.

If you create a control that defines a CSS resource cssTableClass, then use this.getResource(ID_cssTableClass) to get the value of the resource in code.

Control getTagName method

Gets the HTML tag name this control will use for its peer element.

JavaScript

var strVal = control.getTagName()

Remarks

This method is called during rendering to get the name of the HTML tag to use for control's peer element.

Control's implementation method returns the value of the ID_tagName property if it is available, or "span" if no ID_tagName is set.

Subclasses may override this method to specify a different tag name. For example, ContainerControl returns "div" instead of "span" by default.

Returns

An HTML tag name string, e.g. "span", "tr", "div" etc.

Overriden In

Control getValue method (override)

Gets a property, style or attribute.

JavaScript

var obj = control.getValue(propertyId)

Remarks

Overrides SitedObject.getValue() to add support for getting styles and attributes.

Control's getValue method uses the first letter of the specified propertyId string argument to decide what kind of value is being retrieved. If the first character is '@' getValue retrieves the value of an HTML DOM attribute on this control's peer. If the first character is '$', it returns the value of a CSS stylesheet style on this control's peer. Otherwise, propertyId must be an ID name declared using the IdManager, and the value is retrieved from the control itself.

(To remember this, think "@" as in "@ttribute", and "$" as "$tyle").

N.B. This method is safe to call even if the control's peer has not yet been created, since controls retain an internal table of styles and attributes.

Returns

The value of the specified property.

Example

To get the HTML "title" attribute of a control, use:

var title = control.getValue("@title");
alert("The control's title is: " + title);

To get the CSS "height" stylesheet property of a control, use:

var height = control.getValue("$height");
alert("The control's height is: " + height);

To get the controls ID_tagName property, use:

var tagName = control.getValue(ID_tagName);
alert("The control's tagName is: " + tagName);

Base Implementation

See Also

Control getViewState method

Retrieve any viewstate that has been saved for this control in a previous session.

JavaScript

control.getViewState()

Remarks

The viewstate will be in the form of a string, with its value being whatever the control previously saved with Control.setViewState().

Note: this method should be called only in a control's onFirstRender method, as this is both the time at which the data for the control has already been reestablished, and the time at which the control is fully sited within its root site.

Control getViewStateId method

Get a unique and consistent viewstateId for this control.

JavaScript

control.getViewStateId()

Remarks

This id will remain consistent across sessions if the control is reinitialized within a view hierarchy with exactly the same shape.

Control ID_animators property

A SitedList of animators.

JavaScript

var animatorList = control.getValue(ID_animators)
control.setValue(ID_animators, animatorList)

Xml

<j:Control>
<j:Animator ... />
<j:Animator ... />
...
</j:Control>

Remarks

This contains a SitedList of Animator or AnimatorGroup objects that are used by this control to define animations.To start an animator, use Control.startAnimator()To stop an animator, use Control.stopAnimator()

Control ID_controlId property

The ID this control is known in the nearest binding container parent.

JavaScript

var idname = control.getValue(ID_controlId)
control.setValue(ID_controlId, idname)

Xml

<j:Control controlId="string"  ... >

Remarks

When you set this control's ID_controlId, it searches for the nearest binding container parent and registers this control with that binding container's ID_controls map. This means you can refer to this control from other controls in the same binding container, using: #bind(controls.xxx) where xxx is the controlId you use.

Control ID_eventMask property (advanced)

A comma-separated list of peer events this control should receive.

JavaScript

var strVal = control.getValue(ID_eventMask)
control.setValue(ID_eventMask, strVal)

Xml

<j:Control eventMask="string"  ... >

Remarks

You use ID_eventMask to extend which events on the control's peer are wired up to fire Control.onPeerEvent().

By default, only a restricted subset of HTML events on the peer element are setup to fire events in the control hierarchy. You can use eventMask to explicity extend this set of events.

In general, application writers do not need to worry about eventMask - when you add event handlers to a control it automatically sets the relevant flags in eventMask. Sometimes, however, control authors need to receive additional events from the HTML peer. Use eventMask to force the control to wire up events to fire onPeerEvent.

Example

To specify that a control should receive onkeydown and onkeyup events, use:

<MyControl eventMask="keyDown,keyUp" .../>

After doing this, MyControl's onPeerEvent method will be called with ID_keyDown and ID_keyUp events.

Control ID_isBindingContainer property (advanced)

Force this control to act as a binding container.

JavaScript

var boolVal = control.getValue(ID_isBindingContainer)
control.setValue(ID_isBindingContainer, boolVal)

Xml

<j:Control isBindingContainer="true"  ... >
or
<j:Control isBindingContainer="false" ... >

Remarks

Setting ID_isBindingContainer true causes this control to act as a binding container.

When resolving databindings, the binding engine starts with the control the binding is specified on, and searches upwards in the control hierarchy stopping at the first control it encounters whose ID_isBindingContainer property is true. It then traverses the binding path on that binding container.

Control authors typically specify ID_isBindingContainer on a class level - for example, AppControl sets the default for ID_isBindingContainer to true.

You can use the ID_isBindingContainer property lets you specify binding containers on a per-control level.

Control ID_isPeerless property (advanced)

Set this to true to prevent this control from generating a peer element in the rendered HTML.

JavaScript

var boolVal = control.getValue(ID_isPeerless)
control.setValue(ID_isPeerless, boolVal)

Xml

<j:Control isPeerless="true"  ... >
or
<j:Control isPeerless="false" ... >

Remarks

Setting ID_isPeerless to true tells the Control.render() method to skip rendering the tag for this control - instead it only to renders the control's children.

Peerless controls are required in a few rare cases where a control must be present in the control hierarchy for databinding or behavior reasons, but where generating a peer HTML element for the control breaks the HTML or CSS - e.g. because of restrictions in HTML or because of the way the CSS stylesheets were authored.

N.B. Setting this to true breaks many controls.

Control ID_mouseDown event

Event handler called when a mouse button is pressed down.

JavaScript

control.addEventHandler(ID_mouseDown, new Delegate(obj, func))

Xml

<j:Control mouseDown="alert('mouseDown happened')" ... >

Example

In Xml, writing:

<j:Button mouseDown="alert('mouse down');" text="Foo"/>

creates a mouse Down event handler on the Button. When the mouse is pressed down on the button, an alert pops up saying 'mouse down'.

In JavaScript, you write:

// create a click function
function myDown() { alert('Hello'); }

// create a button
var btn = new ButtonControl();

// register myDown as an event handler for the button
btn.addEventHandler(ID_mouseDown, new Delegate(btn, myDown));

Control ID_mouseMove event

Event handler called when the mouse is moved.

JavaScript

control.addEventHandler(ID_mouseMove, new Delegate(obj, func))

Xml

<j:Control mouseMove="alert('mouseMove happened')" ... >

Control ID_mouseOut event

Event handler called when a leaves a control.

JavaScript

control.addEventHandler(ID_mouseOut, new Delegate(obj, func))

Xml

<j:Control mouseOut="alert('mouseOut happened')" ... >

Control ID_mouseOver event

Event handler called when a mouse moves over a control.

JavaScript

control.addEventHandler(ID_mouseOver, new Delegate(obj, func))

Xml

<j:Control mouseOver="alert('mouseOver happened')" ... >

Control ID_mouseUp event

Event handler called when a mouse button is released.

JavaScript

control.addEventHandler(ID_mouseUp, new Delegate(obj, func))

Xml

<j:Control mouseUp="alert('mouseUp happened')" ... >

Control ID_submitters property

A SitedList of submitters.

JavaScript

var submitterList = control.getValue(ID_submitters)
control.setValue(ID_submitters, submitterList)

Xml

<j:Control>
<j:Submitter ... />
<j:Submitter ... />
...
</j:Control>

Remarks

This contains a SitedList of Submitter objects that are used by this control to defer submission of form data.To submit changes, use Control.submitChanges()To reset a submitter, use Control.cancelChanges()

Control ID_tagName property

Overrides the default HTML tag name used for this control.

JavaScript

var strVal = control.getValue(ID_tagName)
control.setValue(ID_tagName, strVal)

Xml

<j:Control tagName="string"  ... >

Remarks

In most cases, each control decides which HTML element to use to render the control, according to properties set on the control. For example, ButtonControl renders as either a "a", "link" or "input" element depending on the value of returned by ButtonControl.getButtonType().

In some cases, control users can override the default HTML tag name used by a control by setting the ID_tagName property.

The most general example is ElementControl, which simply outputs the value of ID_tagName property, enabling applications generate an arbitrary HTML element on the page.

N.B. Setting an ID_tagName property incorrectly will break the rendered HTML or cause the control to function strangely. For example, if you a set LabelControl's tagName property to "img", the label will cease showing the text. Similarly, if you set a control's tagName to "<", this will cause unexpected results.

See Also

Control ID_visible property

True if this control is visible, false if it is hidden.

JavaScript

var boolVal = control.getValue(ID_visible)
control.setValue(ID_visible, boolVal)

Xml

<j:Control visible="true"  ... >
or
<j:Control visible="false" ... >

Remarks

Setting ID_visible to false has the side effect of setting this control's 'visibility' style attribute is set to 'hidden'. Setting ID_visible to true has the side effect of setting this control's 'visibility' style attribute to 'visible'.

This is simply a convenient way of setting the visibility attribute of this control - its particularly useful in databinding, since it saves you having to use a converter to convert true to 'visible' and false to 'hidden'.

Control invalidateLayout method

Tells the layout system to redo layout.

JavaScript

control.invalidateLayout()

Remarks

This searches up the control hierarchy for a control that is either a layout container (such as a dock panel), or a layout root (such as a Popup or AppControl). Then it tells that container to recompute all computed layouts that it has after a brief delay.

Control onBubbleEvent method

Called to handle a bubbled event.

JavaScript

var boolVal = control.onBubbleEvent(sender,bubbleEventArgs)

Remarks

This overridable method is called to handle bubble events.

Return false to stop this event from bubbling further up the control hierarchy, true if the event dispatching should continue.

Some bubble events may have a single optional argument object - see documentation for specific events.

If you override the method, be sure to call the base class's version.

The sender argument is the object that called Control.bubble().

The bubbleEventArgs is a JavaScript object with the following properties:

PropertyDescription
eventIdThe ID of the bubbled event, e.g. ID_selectItem, ID_nextCard, ID_previousCard.
pathAn array of sited objects that the bubble event has been sent to so far. The path[0] is the sender. path[path.length-1] is the object whose site is this object.

Returns

true if dispatching should continue to look for an event handler, false if the event was "consumed" and dispatching should stop.

Overriden In

See Also

Control onDragEvent method

Called to handle a drag drop event..

JavaScript

control.onDragEvent(dragEventArgs)

Remarks

This overridable method is called to process drag drop events. Control's implementation does nothing. Subclasses override this method to add drag drop behavior.

The eventId is one of the following:

ID_dragBeginThe mouse moved after a startDragDrop was called - initiate a drag drop.
ID_dragEnterDuring a drag drop, the mouse entered the bounding box of this control. Show feedback as appropriate.

The control must have the property ID_isDropTarget set to true to receive this message.

ID_dragLeaveDuring a drag drop, the mouse exited the bounding box of this control. Stop showing feedback.

The control must have the property ID_isDropTarget set to true to receive this message.

ID_dragOverThe mouse moved while within this control, during a drag drop. Show appropriate feedback.

The control must have the property ID_isDropTarget set to true to receive this message.

ID_dragEndThe user let go of the mouse button - end the drag and drop interaction.

This is fired on the source control that initiated the drag drop.

Control implementors should look at the dragEventArgs.targetControl - it this is null, the user let go of the mouse outside any drop target, so cancel the drag drop. If it is non-null, it is the target control the objects were dragged onto. This control (the source of the drag drop) should remove the dragged objects from its data model.

ID_dropThe user dropped something on this control.

This is fired on the target control that receives the dropped objects, after ID_dragEnd is called on the source control that started the drag drop. Implementors should add the dropped objects to their data model.

The dragEventArgs is a JavaScript object with the following properties:

eventIdEither ID_dragBegin, ID_dragEnter, ID_dragLeave, ID_dragOver, ID_dragEnd, ID_drop.
dragElementA temporary DOM element used for visual feedback during a drag operation.
objectsThe data objects that are being dragged.
offsetXThe mouse offset X from the left of dragElement.
offsetYThe mouse offset Y from the top of dragElement.
sourceControlThe control that initiated the drag.
targetControlThe current target control where a drop will occur.
peerEventThe XPlatformEvent for the mouse event that caused this message.

Overriden In

Control onFirstRender method

Called the first time a control is rendered.

JavaScript

control.onFirstRender()

Remarks

This overridable method is called the first time a contol is rendered. The default implementation does nothing.

If you override the method, be sure to call the base class's version.

Overriden In

Control onPeerCreated method

Called when a peer is created.

JavaScript

control.onPeerCreated()

Remarks

Override this in control subclasses to do work after the control's peer element has been created.

Control onPeerEvent method

Called to dispatch low level events that arise in the Dom.

JavaScript

var boolVal = control.onPeerEvent(eventId,eventArgs)

Remarks

This method is called whenever an event was generated by this controls peer element in the Dom. It examines the event and calls one of the corresponding onXXX methods, which in turn call fireEventHandler to notify listeners of events.

A side effect of this method is that ID_isMouseOver to true or false when the mouse moves in and out of the control. onPeerEvent It also fires ID_mouseOver, ID_mouseOut, ID_mouseDown, ID_mouseUp and ID_mouseMove user event handlers, by calling SitedObject.fireEventHandler().

Returns

false if an event handler was found that handled the event, true if the event should continue dispatching.

Overriden In

Control onSitedRoot method

Called when a control is added to the main control tree.

JavaScript

control.onSitedRoot()

Remarks

This overridable method is called when the control is added to the main control hierarchy.

If you override the method, be sure to call the base class's version.

Control onUnsitedRoot method

Called when a control is removed from the main control tree.

JavaScript

control.onUnsitedRoot()

Remarks

This overridable method is called when the control is removed from the main control hierarchy.

If you override the method, be sure to call the base class's version.

Control onViewStateChanged method

Overridable. Controls implement this method to update their viewstate.

JavaScript

control.onViewStateChanged()

Remarks

This is required in addition to checking onFirstRender because some browsers don't do a page load when the viewstate changes.

Control reflectOnBoundValue method

Gets runtime reflection information on an underlying bound object.

JavaScript

var propertyInfo = control.reflectOnBoundValue(propertyId)

Remarks

This method is used by a control to query a bound property to discover information about the underlying value. If a property is bound, this returns a PropertyInfo for the underlying bound object, or null if there is no metadata (or if there is no binding or the binding did not resolve).

Returns

An object containing reflection properties, or null if there the specified propertyId is not bound.

Example

The following code inspects the object bound to the ID_text property of a control, and prints its displayName if it exists.

var propertyInfo = obj.reflectOnBoundValue(ID_apply);
if (propertyInfo != null)
   Diagnostics.write(propertyInfo.getValue(ID_displayName));

Control removeClassName method

Removes a CSS class from this controls "class" attribute

JavaScript

control.removeClassName(className)

Control render method

Places the Html representation of this control into the htmlBuilder.

JavaScript

control.render(htmlBuilder)

Remarks

Calling this appends this control's Html markup to the HtmlBuilder's buffer. The generated markup includes Html for the control's peer element and for all the childControls of the control.

This method is used when a control becomes live for the first time, to generate the Html version of the the control to insert in the document.

Subsequently, changes to the control are pushed out to the Html document via direct manipulation of the control's peer element (see Control.getPeer()), or by calling Control.renderChildren() and setting that as the innerHTML of the peer.

Example

The following code obtains a string Html representation of the default app on a page:

var htmlBuilder = new HtmlBuilder();
document.apps[0].render(htmlBuilder);
alert('The html is' + htmlBuilder.toString());

Control renderAttributes method

Called by Control.render() to render attributes for this control.

JavaScript

control.renderAttributes(htmlBuilder)

Remarks

This method uses HtmlBuilder.addAttribute() or HtmlBuilder.addEventAttribute() to add any attributes required by the current control. Control's default implementation outputs an id for the peer, a "cidp" attribute (control id path - an internal attribute used to track this peer), and any user-specified attributes or styles set with Control.setValue().

Subclasses may override this method and add additional control-specific attributes. If you override this method in a control, be sure to call the base-class version.

Overriden In

Control renderChildren method

Places the Html markup for all the Control inside this control into the htmlBuilder.

JavaScript

control.renderChildren(htmlBuilder)

Remarks

This method is called by ContainerControl.render().

Control's default implementation of renderChildren does nothing. Subclasses (e.g. ContainerControl.renderChildren()) override this method to append the inner markup for the control in the htmlBuilder.

Notice that this method does not generate the markup for the control's peer element - that markup is generated automatically by render.

Example

The following code refreshes the Html contents of a control:

var htmlBuilder = new HtmlBuilder();
control.renderChildren(htmlBuilder);
control.getPeer().innerHTML = htmlBuilder.toString();

Overriden In

Control setBounds method

Convenience method to set the left/top/width/height of an element.

JavaScript

control.setBounds(bleft,btop,bwidth,bheight,border)

Remarks

This sets the style.left, style.top, style.width and style.height attributes of an element. Used by computed layouts.

Control setValue method (override)

Sets a property, style or attribute.

JavaScript

control.setValue(propertyId,newVal)

Remarks

Overrides SitedObject.setValue() to add support for styles and attributes.

Control's setValue method uses the first letter of the specified propertyId string argument to decide what kind of value is being set. If the first character is '@', setValue sets the value of an HTML DOM attribute on this control's peer. If the first character is '$', setValue sets the value of a CSS stylesheet style on this control's peer. Otherwise, propertyId must be an ID name declared using the IdManager, and the value is set on the control itself.

(To remember this, think "@" as in "@ttribute", and "$" as "$tyle").

N.B. This method is safe to call even if the control's peer has not yet been created, since controls retain an internal table of styles and attributes.

Example

To set the HTML "title" attribute of a control, use:

control.setValue("@title", 'Hello World');

To set the CSS "left" stylesheet property of a control, use:

control.setValue("$left", '10px');

To set the ID_text property of a button control, use:

button.setValue(ID_text, "Here is the text" );

Base Implementation

See Also

Control setViewState method

Save viewstate that should persist across sessions.

JavaScript

control.setViewState(state)

Remarks

The state should be in the form of a string, and should be kept to a minimal size, since it will be encoded in the URL for the current page. This state should only be saved after the control has been fully sited, and after the control's data is instantiated.

Control startAnimator method

Starts an animation.

JavaScript

control.startAnimator(animatorId)

Remarks

This method searches for an animator with the specified animatorId. If the animator is found, a new animation is scheduled on this control using the matching animator. If no animator is found, this does nothing.

Notice that you can create a single animator and then reuse it on several controls at once. Each time you call startAnimator it launches an independent animation.

Control startDragDrop method

Start a drag drop operation.

JavaScript

control.startDragDrop(objects,existingElement,dragElement,mouseEventArgs)

Control stopAnimator method

Stops an animation.

JavaScript

control.stopAnimator(animatorId)

Remarks

This method searches for an animator with the specified animatorId. If the animator is found, it is told to stop any animations it is running on this control. If no animator is found, this does nothing.