Skip to content

Commit a20be48

Browse files
committed
Updates
1 parent 44c30ab commit a20be48

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

aspnetcore/blazor/javascript-interoperability/call-javascript-from-dotnet.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ An overload is available that takes a <xref:System.Threading.CancellationToken>
493493

494494
### Synchronous `InvokeNew`
495495

496-
Use `InvokeNew(string identifier, object?[]? args)` on <xref:Microsoft.JSInterop.IJSInProcessRuntime> and <xref:Microsoft.JSInterop.IJSInProcessObjectReference> to invoke the specified JS constructor function synchronously. The function is invoked with the `new` operator. In the following example, `TestClass` contains a constructor function, and `classRef` is an <xref:Microsoft.JSInterop.IJSInProcessObjectReference>.
496+
Use `InvokeNew(string identifier, object?[]? args)` on <xref:Microsoft.JSInterop.IJSInProcessRuntime> and <xref:Microsoft.JSInterop.IJSInProcessObjectReference> to invoke the specified JS constructor function synchronously. The function is invoked with the `new` operator. In the following example, `TestClass` contains a constructor function, and `classRef` is an <xref:Microsoft.JSInterop.IJSInProcessObjectReference>:
497497

498498
```csharp
499499
var inProcRuntime = ((IJSInProcessRuntime)JSRuntime);
@@ -521,14 +521,14 @@ window.testObject = {
521521

522522
### Asynchronous `GetValueAsync` and `SetValueAsync`
523523

524-
Use `GetValueAsync<TValue>(string identifier)` to read the value of the specified JS property asynchronously. A <xref:Microsoft.JSInterop.JSException> is thrown if the property doesn't exist or is a `set`-only property.
524+
Use `GetValueAsync<TValue>(string identifier)` to read the value of the specified JS property asynchronously. A <xref:Microsoft.JSInterop.JSException> is thrown if the property doesn't exist or is a `set`-only property. In the following example, the value of `testObject.num` (10) is stored in `valueFromDataPropertyAsync`:
525525

526526
```csharp
527527
var valueFromDataPropertyAsync =
528528
await JSRuntime.GetValueAsync<int>("testObject.num");
529529
```
530530

531-
Use `SetValueAsync<TValue>(string identifier, TValue value)` to update the value of the specified JS property asynchronously. If the property isn't defined on the target object, the property is created. A <xref:Microsoft.JSInterop.JSException> is thrown if the property exists but isn't writable or when a new property can't be added to the object.
531+
Use `SetValueAsync<TValue>(string identifier, TValue value)` to update the value of the specified JS property asynchronously. If the property isn't defined on the target object, the property is created. A <xref:Microsoft.JSInterop.JSException> is thrown if the property exists but isn't writable or when a new property can't be added to the object. In the following example, `testObject.num` is set to 20, and `num2` is created with a value of 30 on `testObject`:
532532

533533
```csharp
534534
await JSRuntime.SetValueAsync("testObject.num", 20);
@@ -537,14 +537,14 @@ await JSRuntime.SetValueAsync("testObject.num2", 30);
537537

538538
### Synchronous `GetValue` and `SetValue`
539539

540-
Use `GetValue<TValue>(string identifier)` to read the value of the specified JS property synchronously. A <xref:Microsoft.JSInterop.JSException> is thrown if the property doesn't exist or is a `set`-only property.
540+
Use `GetValue<TValue>(string identifier)` to read the value of the specified JS property synchronously. A <xref:Microsoft.JSInterop.JSException> is thrown if the property doesn't exist or is a `set`-only property. In the following example, the value of `testObject.num` (10) is stored in `valueFromDataProperty`:
541541

542542
```csharp
543543
var inProcRuntime = ((IJSInProcessRuntime)JSRuntime);
544544
var valueFromDataProperty = inProcRuntime.GetValue<int>("testObject.num");
545545
```
546546

547-
Use `SetValue<TValue>(string identifier, TValue value)` to update the value of the specified JS property synchronously. The property can't be a `get`-only property. If the property isn't defined on the target object, the property is created. A <xref:Microsoft.JSInterop.JSException> is thrown if the property exists but isn't writable or when a new property can't be added to the object.
547+
Use `SetValue<TValue>(string identifier, TValue value)` to update the value of the specified JS property synchronously. The property can't be a `get`-only property. If the property isn't defined on the target object, the property is created. A <xref:Microsoft.JSInterop.JSException> is thrown if the property exists but isn't writable or when a new property can't be added to the object. In the following example, `testObject.num` is set to 20, and `num2` is created with a value of 30 on `testObject`:
548548

549549
```csharp
550550
var inProcRuntime = ((IJSInProcessRuntime)JSRuntime);

0 commit comments

Comments
 (0)