WASM Code Behind access to <input> elements?

This is Water version 11.0.0.2627, with Mercury, trying out the Wasm with Code Behind template.

Are some HTML elements not supported?

I tried adding an input type text to the index.html file, but the code behind doesn’t let me access its attributes.
image

Maybe I’m wrong, but it seems to recognize the input, it just doesn’t know about the “value” attribute. (I’ve also tried “innerHTML” and “innerText” and “class”.)
image

In case it is relevant, I’ve attached my test project.

Just experimenting, so certainly not an emergency.

–Avonelle

WasmWithCodeBehindNoRTLExample.zip (517.4 KB)

I’ll have a look; it probably doesn’t detect the type correctly for it, and types it as base HtmlElement…

I appreciate it. It would be nice to know if I’m doing something wrong, or if there is a bug.

Thanks,

–Avonelle

I’m getting

  Protected Dim WithEvents foo As HTMLInputElement = TryCast(document.getElementById("foo"), HTMLInputElement)

so rthatsa correct; the problem is that this has no significant properties defined…

'''<summary>The HTMLInputElement interface provides special properties and methods for manipulating the options, layout, and presentation of &lt;input> elements.</summary>
<DynamicInterface(GetType(EcmaScriptObject))>
Public Interface [HTMLInputElement]
  '''<summary>on: the browser can autocomplete the value using previously stored value</summary>
  Property [on] As Dynamic
End Interface

I’ll check if that’s correct or if it should have more… these were auto-generated form the DOM docs.

Ah, the problem seems to be that the properties on an ` element change depending in its type… e.g. HTML DOM Input Button Object

I’ll have to see if and how we can support this… for now, you will have to downcast it to Dynamic and access the properties you expect dynamically at runtime, without string type checking :(.

this works

      (foo1 as dynamic).multiple := true;
      (foo1 as dynamic).value := "test";

with foo1 being <input id="foo1" type="email"/>.

Ah, gotcha. Thanks for looking into this, and the work around.

–Avonelle

1 Like

I made the code to support all Input elements the right way - it has to be tested first, but I hope it will be in the next release.

The way I solved it is that I made an interface for each type; the generated code will select the correct interface for the used Html code.

By example, there will be an HtmlInputCheckboxElement.

Good idea. That sounds great!

–Avonelle

1 Like

In for tomorrow’s build.

  Protected Dim WithEvents foo1 As HtmlInputEmailElement = TryCast(document.getElementById("foo1"), HtmlInputEmailElement)
  Protected Dim WithEvents foo2 As HtmlInputTextElement = TryCast(document.getElementById("foo2"), HtmlInputTextElement)
1 Like

Excellent - thanks Marc! Fantastic support as usual.

–Avonelle

2 Likes

:pray:t3: