public void OnActionComplete(ActionEventArgs<Client> args)
{
if (args.RequestType.Equals(Action.Add) || args.RequestType.Equals(Action.BeginEdit))
{
args.PreventRender = false;
}
}
|
|
<Template>
@{
...
<div>
<div class="form-group col-md-6">
<label>Logo</label>
<SfTooltip Target="#img" Content="Select Image" @onclick="onclick">
<img id="img" src=@ImageSourse height="35" />
</SfTooltip>
<InputFile accept="png" ... />
</div>
</div>
}
</Template>
public async Task onclick()
{
await JsRuntime.InvokeAsync<object>("openbrowse");
}
[openbrowse.js]
function openbrowse() {
document.querySelector('input[type=file]').click();
}
|
It is possible to do the same by replacing InputFile on SfUploader?
Hi Kavit,
Greetings from Syncfusion.
As per the requirement, we have prepared a sample by replacing the inputFile with the Syncfusion File Upload component and ValueChange event. Refer the below code snippets
|
<Template> @{ var entity = (context as Client); ImageSourse = string.Format("data:image/png;base64,{0}", entity.Logo != null ? Convert.ToBase64String(entity.Logo) : null); <div> <div class="form-group col-md-6"> <label>Logo</label> <SfTooltip Target="#img" Content="Select Image" @onclick="onclick"> <img id="img" src=@ImageSourse height="35" /> </SfTooltip> <SfUploader AllowedExtensions=".png" AllowMultiple="false"> <UploaderEvents ValueChange="@(async (args) => { var file = args.Files[0]; byte[] Logo = file.Stream.ToArray(); entity.Logo = Logo; })"> </UploaderEvents> </SfUploader> </div> </div> } </Template>
|
However, we have prepared sample for your reference which you can download from the below link
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/ServerApp_Grid_uploader695162192
Regards,
Joshna L