<EjsUploader @ref="fileUploadObj" ID="UploadFiles">
<UploaderAsyncSettings SaveUrl="api/SampleData/Save" RemoveUrl="api/SampleData/Remove"></UploaderAsyncSettings>
</EjsUploader>
<div>
<p>Uploaded File Name is: @FileName</p>
<p>Removed File Name is: @Removing</p>
</div>
@code{
EjsUploader fileUploadObj;
public string FileName;
public string Removing;
public void OnSuccess(object args)
{
//Deserialized the success event args using Newton soft.
SuccessEventArgs eventArgs = JsonConvert.DeserializeObject<SuccessEventArgs>(args.ToString());
// Assign the file name in the variable
FileName = eventArgs.File.Name;
// To reflect the DOM content
this.StateHasChanged();
}
//Success event args class.
public class SuccessEventArgs
{
public object E { get; set; }
public FileInfo File { get; set; }
public string StatusText { get; set; }
public string Name { get; set; }
public string Operation { get; set; }
public ResponseEventArgs Response { get; set; }
}
public class ResponseEventArgs
{
public string Headers { get; set; }
public object ReadyState { get; set; }
public object StatusCode { get; set; }
public string StatusText { get; set; }
public bool withCredentials { get; set; }
}
public void OnFileRemove(RemovingEventArgs args)
{
Removing = args.FilesData[0].Name;
StateHasChanged();
}
protected override void OnAfterRender()
{
this.fileUploadObj.OnRemove = this.OnFileRemove;
this.fileUploadObj.Success = this.OnSuccess;
}
} |
<EjsUploader @ref="fileUploadObj" ID="UploadFiles">
<UploaderAsyncSettings SaveUrl="api/SampleData/Save" RemoveUrl="api/SampleData/Remove"></UploaderAsyncSettings>
</EjsUploader>
<div>
<p>Uploaded File Name is: @FileName</p>
<p>Removed File Name is: @Removing</p>
</div>
@code{
EjsUploader fileUploadObj;
public string FileName;
public string Removing;
protected override void OnAfterRender()
{
this.fileUploadObj.OnRemove = this.OnFileRemove;
this.fileUploadObj.Success = this.OnSuccess;
}
public void OnFileRemove(RemovingEventArgs args)
{
Removing = args.FilesData[0].Name;
StateHasChanged();
}
public void OnSuccess(object args)
{
//Deserialized the success event args using Newton soft.
SuccessEventArgs eventArgs = JsonConvert.DeserializeObject<SuccessEventArgs>(args.ToString());
// Assign the file name in the variable
FileName = eventArgs.File.Name;
// To reflect the DOM content
this.StateHasChanged();
}
//Success event args class.
public class SuccessEventArgs
{
public object E { get; set; }
public FileInfo File { get; set; }
public string StatusText { get; set; }
public string Name { get; set; }
public string Operation { get; set; }
public ResponseEventArgs Response { get; set; }
}
public class ResponseEventArgs
{
public string Headers { get; set; }
public object ReadyState { get; set; }
public object StatusCode { get; set; }
public string StatusText { get; set; }
public bool withCredentials { get; set; }
}
} |