Class

WebControl


Description

The common super class for all web controls that can appear in the browser. It cannot be instantiated or subclassed.

Properties

Name

Type

Read-Only

Shared

ControlID

String

Enabled

Boolean

Name

String

Page

WebPage

Parent

WebView

Methods

Name

Parameters

Returns

Shared

Close

ExecuteJavaScript

Script As String

GoToURL

Url As String, inNewWindow As Boolean = False

UpdateBrowser

Events

Name

Parameters

Returns

Closed

Opening

Property descriptions


WebControl.ControlID

ControlID As String

Identifies the control on a per session basis.

This property is read-only.


WebControl.Enabled

Enabled As Boolean

When True the WebControl is drawn enabled and responds to user action. When False, the control appears as disabled and does not respond to user actions.

In the case of WebTimer, when set to False this disables and stops the WebTimer. When set to True, it starts the WebTimer.

Disable a button when a check box value changes:

If AllowSaveCheckBox.Value Then
  SaveButton.Enabled = True
Else
  AllowSaveButton.Enabled = False
End If

WebControl.Name

Name As String

The name of the control.

This property is read-only.


WebControl.Page

Page As WebPage

Identifies the web page that contains the control.

This property is read-only.


WebControl.Parent

Parent As WebView

Used to get the control's parent control or page. If the parent control is a WebContainer, then it returns the WebContainer. If it is on a WebPage, it returns the WebPage.

This property is read-only.

Method descriptions


WebControl.Close

Close

Removes the control from the page.


WebControl.ExecuteJavaScript

ExecuteJavaScript(Script As String)

Executes the JavaScript passed. The JavaScript passed can call a JavaScript function in a WebPageSource control.

The Xojo web framework uses EcmaScript 6 which is more strict than previous versions of JavaScript. For more details, see the EcmaScript 6 documentation.

This code in the Pressed event of a Button displays an alert using JavaScript:

Me.ExecuteJavaScript("alert('Hello!');")

This code will select the text in a WebTextField (or WebTextArea):

WebTextField1.ExecuteJavascript("document.getElementById('" + _
  WebTextField1.ControlID + "_inner').select();")

WebControl.GoToURL

GoToURL(Url As String, inNewWindow As Boolean = False)

Opens the passed URL in place of the current web page or downloads a file. If InNewWindow is True, the browser is asked to open the URL in a new window.

If the browser has popup windows disabled and InNewWindow is True, the method silently fails and the page is not shown.

If InNewWindow is False, the running web app is replaced with the specified URL. If you want to display an external web site within your web app, use the WebHTMLViewer control.

Display a web site in a new popup window:

Me.GoToURL("http://www.wikipedia.org", True)

WebControl.UpdateBrowser

UpdateBrowser

Forces the current values of the control to be sent to the browser.

This method is useful when you are computing values in a loop and wish to update the browser immediately rather than wait until the current method ends.

This code iterates through a RowSet of database rows, updates a ProgressBar and then forces the updated ProgressBar to be sent to the browser via UpdateBrowser.

ProgressBar1.Maximum = SalesData.RowCount
For Each row As DatabaseRow in SalesData
 AnalyzeSales(row)
 ProgressBar1.Value = ProgressBar1.Value + 1
 ProgressBar1.UpdateBrowser
Next

Event descriptions


WebControl.Closed

Closed

The control has been removed from the page either because the page has closed or the control's Close method was called.


WebControl.Opening

Opening

The control has been created and the page is opening but has not been sent to the browser yet.

The Opening event handler can be used to initialize non-visual properties and settings for controls.

In most cases, you should use the Shown event to initialize controls.

Compatibility

Web projects on all supported operating systems.

See also

Object parent class; WebDialog, WebPage classes