Class

# WebSDKControl

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

<span class="title-ref">WebSDKControl</span> is a direct subclass of `WebControl</api/user_interface/web/webcontrol>`.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                   | Type                                       | Read-Only | Shared |
|----------------------------------------|--------------------------------------------|-----------|--------|
| `ControlID<websdkcontrol.controlid>`   | `String</api/data_types/string>`           | ✓         |        |
| `Enabled<websdkcontrol.enabled>`       | `Boolean</api/data_types/boolean>`         |           |        |
| `Name<websdkcontrol.name>`             | `String</api/data_types/string>`           | ✓         |        |
| `Page<websdkcontrol.page>`             | `WebPage</api/user_interface/web/webpage>` | ✓         |        |
| `PanelIndex<websdkcontrol.panelindex>` | `Integer</api/data_types/integer>`         |           |        |
| `Parent<websdkcontrol.parent>`         | `WebView</api/user_interface/web/webview>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                       | Parameters                                                                                                                | Returns                            | Shared |
|------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|------------------------------------|--------|
| `Close<websdkcontrol.close>`                               |                                                                                                                           |                                    |        |
| `ExecuteJavaScript<websdkcontrol.executejavascript>`       | script As `String</api/data_types/string>`                                                                                |                                    |        |
| `FrameworkLibraryURL<websdkcontrol.frameworklibraryurl>`   | libraryFileName As `String</api/data_types/string>`                                                                       |                                    |        |
| `GoToURL<websdkcontrol.gotourl>`                           | url As `String</api/data_types/string>`, inNewWindow As `Boolean</api/data_types/boolean>` = `False</api/language/false>` |                                    |        |
| `LazyLoadDependencies<websdkcontrol.lazyloaddependencies>` |                                                                                                                           | `Boolean</api/data_types/boolean>` |        |
| `UpdateBrowser<websdkcontrol.updatebrowser>`               |                                                                                                                           |                                    |        |
| `UpdateControl<websdkcontrol.updatecontrol>`               | sendImmediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`                                      |                                    |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                         | Parameters                                                                                    | Returns                            |
|--------------------------------------------------------------|-----------------------------------------------------------------------------------------------|------------------------------------|
| `Closed<websdkcontrol.closed>`                               |                                                                                               |                                    |
| `ExecuteEvent<websdkcontrol.executeevent>`                   | name As `string</api/data_types/string>`, parameters As `JSONItem</api/text/json/jsonitem>`   | `Boolean</api/data_types/boolean>` |
| `HandleRequest<websdkcontrol.handlerequest>`                 | request As `WebRequest</api/web/webrequest>`, response As `WebResponse</api/web/webresponse>` | `Boolean</api/data_types/boolean>` |
| `JavaScriptClassName<websdkcontrol.javascriptclassname>`     |                                                                                               | `String</api/data_types/string>`   |
| `Opening<websdkcontrol.opening>`                             |                                                                                               |                                    |
| `Serialize<websdkcontrol.serialize>`                         | js As `JSONItem</api/text/json/jsonitem>`                                                     |                                    |
| `SessionHead<websdkcontrol.sessionhead>`                     | session As `WebSession</api/web/websession>`                                                  | `String</api/data_types/string>`   |
| `SessionJavascriptURLs<websdkcontrol.sessionjavascripturls>` | session As `WebSession</api/web/websession>`                                                  | `String()</api/data_types/string>` |

## Constants

> These constants are designed to be used with the <span class="title-ref">WebSDKControl</span>.
>
> | Name       | Description                    |
> |------------|--------------------------------|
> | APIVersion | WebSDK API version. 2020r1 = 7 |

## Property descriptions

<div id="websdkcontrol.controlid">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.ControlID

**ControlID** As `String</api/data_types/string>`

> Identifies the control on a per session basis.
>
> This property is read-only.

<div id="websdkcontrol.enabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.Enabled

**Enabled** As `Boolean</api/data_types/boolean>`

> When `True</api/language/true>` the **WebControl** is drawn enabled and responds to user action. When `False</api/language/false>`, the control appears as disabled and does not respond to user actions.
>
> In the case of `WebTimer</api/web/webtimer>`, when set to `False</api/language/false>` this disables and stops the WebTimer. When set to `True</api/language/true>`, it starts the WebTimer.
>
> Disable a button when a check box value changes:
>
> ``` xojo
> If AllowSaveCheckBox.Value Then
>   SaveButton.Enabled = True
> Else
>   AllowSaveButton.Enabled = False
> End If
> ```

<div id="websdkcontrol.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.Name

**Name** As `String</api/data_types/string>`

> The name of the control.
>
> This property is read-only.

<div id="websdkcontrol.page">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.Page

**Page** As `WebPage</api/user_interface/web/webpage>`

> Identifies the web page that contains the control.
>
> This property is read-only.

<div id="websdkcontrol.panelindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.PanelIndex

**PanelIndex** As `Integer</api/data_types/integer>`

> If the control has been placed on a <span class="title-ref">WebTabPanel</span> or `WebPagePanel</api/user_interface/web/webpagepanel>` control, this is the panel (page/tab) that the control is on. If the control is not on a panel, it returns -1.
>
> The first panel is numbered zero. If the control has been placed on a panel of a <span class="title-ref">WebTabPanel</span> or `WebPagePanel</api/user_interface/web/webpagepanel>` control, it returns the panel number. If the control is not on a `WebPagePanel</api/user_interface/web/webpagepanel>` or <span class="title-ref">WebTabPanel</span>, it returns -1. If you change the PanelIndex to a nonexistent panel, the control will disappear until you give it a PanelIndex value that corresponds to a panel that exists.
>
> If you are looking to change the currently selected panel (page/tab), use `SelectedPanelIndex<webpagecontrol.selectedpanelindex>`.
>
> This code displays the panel index of the control that is on the page.
>
> ``` xojo
> MessageBox(Me.SelectedPanelIndex.ToString)
> ```

<div id="websdkcontrol.parent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.Parent

**Parent** As `WebView</api/user_interface/web/webview>`

> Used to get the control's parent control or page. If the parent control is a `WebContainer</api/user_interface/web/webcontainer>`, then it returns the `WebContainer</api/user_interface/web/webcontainer>`. If it is on a `WebPage</api/user_interface/web/webpage>`, it returns the `WebPage</api/user_interface/web/webpage>`.
>
> This property is read-only.

## Method descriptions

<div id="websdkcontrol.close">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.Close

**Close**

> Removes the control from the page.

<div id="websdkcontrol.executejavascript">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.ExecuteJavaScript

**ExecuteJavaScript**(script As `String</api/data_types/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](https://www.ecma-international.org/ecma-262/6.0/).
>
> This code in the Pressed event of a Button displays an alert using JavaScript:
>
> ``` xojo
> Me.ExecuteJavaScript("alert('Hello!');")
> ```
>
> This code will select the text in a WebTextField (or WebTextArea):
>
> ``` xojo
> WebTextField1.ExecuteJavascript("document.getElementById('" + _
>   WebTextField1.ControlID + "_inner').select();")
> ```

<div id="websdkcontrol.frameworklibraryurl">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.FrameworkLibraryURL

**FrameworkLibraryURL**(libraryFileName As `String</api/data_types/string>`)

> Returns the URL for a library filename available in the Xojo Web Framework. It's meant to be used in the `SessionJavascriptURLs<websdkcontrol.sessionjavascripturls>` event. For example, the following code will return the URLs for the Moment.js library:
>
> ``` xojo
> Var result() As String
>
> result.Add(FrameworkLibraryURL("moment-with-locales.min.js"))
> result.Add(FrameworkLibraryURL("moment-timezone-with-data.min.js"))
>
> Return result
> ```

<div id="websdkcontrol.gotourl">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.GoToURL

**GoToURL**(url As `String</api/data_types/string>`, inNewWindow As `Boolean</api/data_types/boolean>` = `False</api/language/false>`)

> Opens the passed *url* in place of the current web page or downloads a file. If *inNewWindow* is `True</api/language/true>`, the browser is asked to open the *url* in a new window.
>
> If the browser has popup windows disabled and *inNewWindow* is `True</api/language/true>`, the method silently fails and the page is not shown.
>
> If *inNewWindow* is `False</api/language/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</api/user_interface/web/webhtmlviewer>` control.
>
> Display a web site in a new popup window:
>
> ``` xojo
> Me.GoToURL("http://www.wikipedia.org", True)
> ```

<div id="websdkcontrol.lazyloaddependencies">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.LazyLoadDependencies

**LazyLoadDependencies** As `Boolean</api/data_types/boolean>`

> This is a method that can be overridden by subclasses. By default it returns `False</api/language/false>`. Returning `True</api/language/true>` will lazy load CSS and JS dependencies for that control. If it's `False</api/language/false>` or the method hasn't been overridden, it won't do any lazy loading, everything will be downloaded when the framework creates the Session for that user.

<div id="websdkcontrol.updatebrowser">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.UpdateBrowser

**UpdateBrowser**

> Similar to the method on `WebControl</api/user_interface/web/webcontrol>`, this method also sets the internal flag which indicates to the framework that your control needs a refresh on the browser and then immediately sends the update to the browser.

<div id="websdkcontrol.updatecontrol">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.UpdateControl

**UpdateControl**(sendImmediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`)

> Similar to the UpdateBrowser method, this method also sets the internal flag which indicates to the framework that your control needs a refresh on the browser. When *sendImmediately* is `False</api/language/false>`, any changes made are deferred until the event loop completes. When *sendImmediately* is `True</api/language/true>`, the changes will be sent at that very moment.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> Calling this method with *sendImmediately* set to `True</api/language/true>` will override the "deferred" option of any changes before it was called.
>
> </div>

## Event descriptions

<div id="websdkcontrol.closed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.Closed

**Closed**

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

<div id="websdkcontrol.executeevent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.ExecuteEvent

**ExecuteEvent**(name As `string</api/data_types/string>`, parameters As `JSONItem</api/text/json/jsonitem>`) As `Boolean</api/data_types/boolean>`

> This event fires when an event is sent from the browser to the app using the triggerServerEvent JavaScript method. Return `True</api/language/true>` if your control has handled the event.

<div id="websdkcontrol.handlerequest">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.HandleRequest

**HandleRequest**(request As `WebRequest</api/web/webrequest>`, response As `WebResponse</api/web/webresponse>`) As `Boolean</api/data_types/boolean>`

> This event fires in the same way as App.HandleURL does except that it is for requests that are only for the current control.
>
> To trigger this event you will need to create a specially formed URL:
>
> ``` xojo
> Var url As String = "https://www.yourdomain.com/sdk/" + Self.ControlID
> ```
>
> See the documentation for `WebApplication.HandleURL<webapplication.handleURL>` for usage information.

<div id="websdkcontrol.javascriptclassname">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.JavaScriptClassName

**JavaScriptClassName** As `String</api/data_types/string>`

> This event fires when the control is first created to send the JavaScript constructor for your control to the browser.

<div id="websdkcontrol.opening">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.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<webuicontrol.shown>` event to initialize controls.

<div id="websdkcontrol.serialize">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.Serialize

**Serialize**(js As `JSONItem</api/text/json/jsonitem>`)

> This event fires when the framework sends the first configuration to your control in the browser, whenever a property on WebControl is changed and whenever you call the Xojo UpdateBrowser method.

<div id="websdkcontrol.sessionhead">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.SessionHead

**SessionHead**(session As `WebSession</api/web/websession>`) As `String</api/data_types/string>`

> This event fires each time a new session starts. You should return a `String</api/data_types/string>` containing the items you wish to add to the `<head>` tag.

<div id="websdkcontrol.sessionjavascripturls">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebSDKControl.SessionJavascriptURLs

**SessionJavascriptURLs**(session As `WebSession</api/web/websession>`) As `String()</api/data_types/string>`

> This event fires each time a new session starts. You should return an array of URLs which point to any javascript you need for your control to function, whether it be a subclass of XojoControl or an external library. The Xojo framework will attempt to prevent duplicate URLs from being sent to the same session.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> One reason we supply the session object is so you can figure out whether or not items have already been delivered to a particular session.
>
> </div>

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | Web |
| **Operating Systems** | All |

<div class="seealso">

`WebControl</api/user_interface/web/webcontrol>` parent class

</div>
