UnmatchedParameters { get; set; }
@@ -9,6 +16,10 @@
[Parameter] public int MaxMessageSize { get; set; } = 20 * 1024; // TODO: Use SignalR default
[Parameter] public int MaxBufferSize { get; set; } = 1024 * 1024;
+
+ [Parameter] public string ElementId { get; set; } // this id is used by the js function 'wrapInput' which calls click()
+ [Parameter] public bool IsElementHidden { get; set; } = false;
+
ElementReference inputFileElement;
IDisposable thisReference;
diff --git a/BlazorInputFile/wwwroot/inputfile.js b/BlazorInputFile/wwwroot/inputfile.js
index 13e7ab3..a714a6b 100644
--- a/BlazorInputFile/wwwroot/inputfile.js
+++ b/BlazorInputFile/wwwroot/inputfile.js
@@ -63,6 +63,10 @@
destinationUint8Array.set(sourceUint8Array, destinationOffset);
return bytesToRead;
+ },
+
+ wrapInput: function wrapInput(elementId) {
+ document.getElementById(elementId).click();
}
};
From 878d973222a23aee246ddb4d5619cc872b43b963 Mon Sep 17 00:00:00 2001
From: Eric Rosenfeld <46537274+r0si@users.noreply.github.com>
Date: Fri, 1 Nov 2019 18:32:11 +0100
Subject: [PATCH 2/3] Update README.md
---
README.md | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/README.md b/README.md
index 8495067..a26c500 100644
--- a/README.md
+++ b/README.md
@@ -3,3 +3,36 @@
This is a prototype for a file input component that may be added to Blazor in the future.
For installation and usage information, see [this blog post](http://blog.stevensanderson.com/2019/09/13/blazor-inputfile/).
+
+## Using a custom button with MatBlazor:
+
+```csharp
+
+
+
+@if (file != null)
+{
+ Name: @file.Name
+ Size in bytes: @file.Size
+ Last modified date: @file.LastModified.ToShortDateString()
+ Content type (not always supplied by the browser): @file.Type
+}
+
+@code {
+
+ public async void OnButtonClick(string elementID)
+ {
+ await JSRuntime.InvokeAsync("BlazorInputFile.wrapInput", elementID);
+ }
+
+ IFileListEntry file;
+
+ void HandleFileSelected(IFileListEntry[] files)
+ {
+ file = files.FirstOrDefault();
+ }
+
+}
+```
+
+Reference from [here](https://stackoverflow.com/a/9546968)
From a5c99fd25f5ec5304ca0894f87c1284ee369a9c5 Mon Sep 17 00:00:00 2001
From: Eric Rosenfeld <46537274+r0si@users.noreply.github.com>
Date: Fri, 1 Nov 2019 18:33:42 +0100
Subject: [PATCH 3/3] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a26c500..74e14ba 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ For installation and usage information, see [this blog post](http://blog.stevens
```csharp
-
+
@if (file != null)
{